why my customized marker not showing up in openstreet maps

Posted by troy on Stack Overflow See other posts from Stack Overflow or by troy
Published on 2012-10-15T15:35:15Z Indexed on 2012/10/15 15:37 UTC
Read the original article Hit count: 199

Filed under:

I have following java script used for showing the customized marker. But for some reasons its showing up the default marker..

 function init() {
        map = new OpenLayers.Map("basicMap");
        var mapnik         = new OpenLayers.Layer.OSM();
        var fromProjection = new OpenLayers.Projection("EPSG:4326");   
        var toProjection   = new OpenLayers.Projection("EPSG:900913"); 
        var position       = new OpenLayers.LonLat(-6.242981,53.331201).transform( fromProjection, toProjection);
        var zoom           = 12; 
        map.addLayer(mapnik);

        var markers = new OpenLayers.Layer.Markers( "Markers" );
        map.addLayer(markers);
        var size = new OpenLayers.Size(16,28);
        var offset = new OpenLayers.Pixel(-(size.w*0), -(size.h*1));
        var icon = new OpenLayers.Icon('http://m.osmtools.de/images/pin_red.png',size,offset);
        markers.addMarker(new OpenLayers.Marker(position),icon);
        map.setCenter(position, zoom );
      }

And here is my html:

<body onload="init();">
    <div id="basicMap"></div>
</body>

I dont understand what wrong with my code .... Please help me.. THank You

© Stack Overflow or respective owner

Related posts about openstreetmap