4 :: Multiple Markers on an OpenStreetMap

Today I’m going to revisit the short P2PU course that introduced me to online mapping a little over two years ago. At that time, I didn’t fully appreciate or make sense of the JavaScript that was involved and what it meant to reference a JavaScript library.

We had an assignment to place a marker on an OpenStreetMap and I wanted to add a variety of markers but couldn’t figure out how.  Luckily, I had some great help that went like this:

Here’s the process:

1) Create new layerStyle
2) Create new pointLayer (for all points)
3) Add pointLayer to map
4) Create new sampleStyle (for several points)
5) Create new point
6) Create pointFeature based on point and sampleStyle
7) Add attributes to pointFeature
8) Add pointFeature to pointLayer

In your code, you jump back to the beginning, and create new layers. Only the last layer (with the last point) is being sent to the SelectControl, so only that one works. Instead, go back to Step 5 to create a new point and add it to the same layer. Or go back to Step 4 if you’re changing the style. So you want to have these lines only once, at the beginning…

I remember struggling with this guidance but somehow I got it to work.

Leave a Reply

Your email address will not be published. Required fields are marked *