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's gravatar image

Lizzy7
11112
accept rate: 0%

closed 26 Feb '13, 08:04

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
71.3k846451113

The question has been closed for the following reason "Question is off-topic or not relevant" by Frederik Ramm 26 Feb '13, 08:04


This is not an OpenLayers support forum. See www.openlayers.org for help on OpenLayers. There's a multi-marker example here: http://openlayers.org/dev/examples/markers.html

permanent link

answered 26 Feb '13, 08:03

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
71.3k846451113
accept rate: 24%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×47
×46
×30

question asked: 26 Feb '13, 07:48

question was seen: 4,520 times

last updated: 26 Feb '13, 08:04

powered by OSQA