OpenLayers Tutorial – Place a Marker
Sunday, March 27th, 2011This post continues our series of OpenLayers tutorials. If you are new to OpenLayers, review our basic map setup tutorial before continuing.
A common task of any mapping application is to place a marker at a specified location. OpenLayers provides several options for doing this but we will focus on using a Marker.
Our simple example will allow a user to plot the location of various US cities on an OpenLayers map. In order to accomplish this, we need to know the longitude (X) and latitude (Y) of each city. We will use this list of city coordinates to create a HTML <select> box.
<select id="jumpTo" onchange="jumpTo();"> <option value="NA">=== Select a City ===</option> <option value="-84.42,33.65">Atlanta</option> <option value="-104.87,39.75">Denver</option> <option value="-95.35,29.97">Houston</option> <option value="-81.32,28.43">Orlando</option> <option value="-121.50,38.52">Sacramento</option> <option value="-95.62,39.07">Topeka</option> </select>