[OpenLayers-Users] multiple Markers?????

Eric Lemoine eric.c2c at gmail.com
Thu Aug 30 02:36:39 EDT 2007


On 8/30/07, Prasad Choudhary <prasad.choudhary at gmail.com> wrote:
> Hello List,

Hi


>
> I want to render the base map with miltiple markers for that the code i put
> is like
>
> <code>
>
> putMakers = function(){
>    var size = new OpenLayers.Size(12,20);
>    var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
>    icon = new
> OpenLayers.Icon('../img/marker_20_blue.png',size,offset);
>
>    markerArray = new Array(myData.length);
>
>    for(var i=0; i< myData.length; i++)
>    {
>     locLonLat = new OpenLayers.LonLat(myData[i][1],myData[i][0]);
>     markerArray[i] = new OpenLayers.Marker (locLonLat,icon);
>     markerLayer.addMarker(markerArray[i]);
>    }
> }
>
> </code>
>
> Markers are creating but vanishing and I am able to see only last marker
> location only
> can any one tell me why it is so????
>
> is there any other better solution for this!!

Try creating a new icon for every new marker. I haven't actually
checked whether that'd work out, but using one icon for every marker
seems problematic to me.

--
Eric



More information about the Users mailing list