Hi All
I am new to this and need to complete an assignment, i am unable to add three additional markers into this code, i found the below info but it still doesnt help me.
//ADD LAYER MARKERS
var markers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(lonLat,icon));
Below is the code, i have tried to copy "var lonLat = new OpenLayers.LonLat( 13.0 ,47.0 ) //define a new location with these coordinates in WGS84" with new lat lon 13.1, 47.8 but that doesnt work.
WHAT AM I DOING WRONG, PLEASE HELP ME ....
<!-- COPYRIGHT: http://wiki.openstreetmap.org -->
<html>
<head>
<title>OpenLayers Demo</title>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
function init() {
map = new OpenLayers.Map("mapdiv"); //create a new map
var mapnik = new OpenLayers.Layer.OSM(); //add an OpenStreetMap layer to have some data in the mapview
map.addLayer(mapnik); //add the OSM layer to the map
var vectorLayer = new OpenLayers.Layer.Vector // Overlay new line
var feature = new OpenLayers.Feature.Vector // new line
var markers = new OpenLayers.Layer.Markers( "Markers" ); //add a layer where markers can be put
map.addLayer(markers); //add the markers layer to the current map
var lonLat = new OpenLayers.LonLat( 13.0 ,47.0 ) //define a new location with these coordinates in WGS84
.transform( //transform the location to the coordinate system of our OpenLayers map
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
markers.addMarker(new OpenLayers.Marker(lonLat, icon)); //add the newly created marker to the markers layer
map.setCenter(lonLat, 13); // Use maker to center the map above and set zoom level to 15
}
</script>
</head>
<body onload="init();">
<div style="width: 100%; height: 100%;" id="mapdiv"></div>
---Here I describe how I solved the assignment---
</body>
</html>
asked
26 Feb '13, 07:48
Lizzy7
11●1●1●2
accept rate:
0%