javascript - OpenLayers Markers with custom Text / Label -


i have "n" markers on openlayers map , need "label" these markers (meaning: put text in/on them) have tried several ways still couldn't achieve need.

my js code snippet (removed irrevelant stuff code):

function getweatherinfo(){ if(wheatherofcitiesmarkerlayer == null){     wheatherofcitiesmarkerlayer = new openlayers.layer.markers("weathermarkerlayer");     map.addlayer(wheatherofcitiesmarkerlayer); }  $.getjson(qrypointresultlistforallcities(),  function(data) {        if(data!= null){         var size = new openlayers.size(60,45);         var offset = new openlayers.pixel(-(size.w/2), -size.h);          for(var = 0; < data.pr.length; ++){                 // create markers using returned data server             //...             //... removed irrevelant stuff              var lat = data.pr[i].la;             var lon = data.pr[i].lo;             var infos = data.pr[i].info.infos;             var infop = data.pr[i].info.infop;             var infocc = data.pr[i].info.infocc;              var icon = new openlayers.icon('my_marker_img.png',size,offset);              location = new openlayers.lonlat(lon, lat);             location = transformfromwgs1984tosphericalmercator(location.clone());             marker = new openlayers.marker(location,icon.clone());              wheatherofcitiesmarkerlayer.addmarker(marker);          }      }  }  } 

what need put label or text in/on each marker on map.

since taking marker data server anyway, can is, create layer in map file label class defined , add on marker layer overlay.

hope helps.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -