AW: [OpenLayers-Users] Need your Help: Overlapping Markers even after having different LATITUDE and LONGITUDE

Arnd Wippermann arnd.wippermann at web.de
Thu Aug 4 15:55:02 EDT 2011


Hi,
 
OSM layer are displayed in the projection EPSG:900913. You have to transform
your coordinates from EPSG:4326 to EPSG:900913.
 
Arnd
 
    <script>
 
 var map, layer;
 
    var P4326   = new OpenLayers.Projection("EPSG:4326");
    var P900913 = new OpenLayers.Projection("EPSG:900913");
 
      function init() {
 

        map = new OpenLayers.Map("map_id", { projection: P900913 });
        var mapnik = new OpenLayers.Layer.OSM();
 
        map.addLayer(mapnik);
        map.setCenter(new OpenLayers.LonLat(0,0), 3) ;
 
        map.addControl(new OpenLayers.Control.Graticule());
 
        var markers = new OpenLayers.Layer.Markers( "Markers" );
        var size = new OpenLayers.Size(21,25);
        var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
 
        map.addLayer(markers);
 
        var icon0 = new
OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size,
offset);
        var icon1 = new
OpenLayers.Icon('http://www.openlayers.org/dev/img/marker-blue.png', size,
offset);
 
        var m1 = new OpenLayers.Marker(new OpenLayers.LonLat(0,0),icon0);
        var m2 = new OpenLayers.Marker(new
OpenLayers.LonLat(40,20).transform(P4326,P900913),icon1);
 
        markers.addMarker(m1);
        markers.addMarker(m2);
 

      }
    </script>


  _____  

Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Chatur
Patil
Gesendet: Donnerstag, 4. August 2011 19:53
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] Need your Help: Overlapping Markers even after
having different LATITUDE and LONGITUDE


Dear Users,
 
Re-sending as I received a failure delivery .

I am facing a unique problem with overlapping marker Icons, in-spite placing
them at different LATITUDE and LONGITUDE.

I am using OSM Layer for the map. When I add multiple markers they are
placed one over the other even though there is change in latitude and
longitude.
Issue is that the markers are placed centrally on the map irrespective of
the specified latitude and longitude. I have just attached the whole HTML
file for reference.

There is no much coding in the attached file, its very simple (just create
the map and add 2 markers)

Could you please tell me If I am doing anything wrong. I have tried all
possible ways.

Your help is much appreciated.
Many Thanks, 
Chatur


PS: I raised a bug ticket
http://trac.osgeo.org/openlayers/ticket/3450#comment:2  to explain the
issue.
      Indication was tha,t it could be something to do with the projections,
hence I removed all projections and still face the same issue :(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110804/7c68cdc4/attachment.html


More information about the Users mailing list