javascript - Leaflet how to combine icons and circle markers in the same layergroup -


i have bunch of coordinates add onto leaflet map. coordinates tagged value "home" home-like svg icon , stored in homeicons variable. other coordinates circular marker , stored in variable called circles. current approach succeeds in turning circles proper leaflet object not homeicons. time combine them layer group using l.layergroup(), objects 'homeicons' dropped out. please let me know if see problem code is. thank you!

    var circles = [];     var homeicons = [];      var markeroptions = {       radius      : 10,       fillcolor   : 'yellow',       color       : 'null',       weight      : 1,       opacity     : 1,       fillopacity : 0.8     };      var homeicon = l.icon({       iconurl: 'public/imgs/home_icon.svg',       iconsize     : [30, 30],       iconanchor   : [8, 18],       popupanchor  : [0, -15],     });      var homemarker = l.marker([null, null], {icon: homeicon, opacity: 1});      (var i=0; i<data.length; i++) {       var pois = json.parse(data[i].pois);        (var n=0; n<pois.length; n++) {         homemarker = {latlng:[pois[n].lat, pois[n].lng], name: data[i].name};           if (pois[n].poitag == "home") {         homeicons.push(l.marker(homemarker));         } else {         circles.push(l.circlemarker([pois[n].lat, pois[n].lng], markeroptions, {name: data[i].name}));         }       }     }      console.log(circles);    // outputs array of leaflet objects     console.log(homeicons);  // not outputing array of objects similar properties leaflet objects      var alllayers = l.layergroup(circles, homeicons);  // supposed add both circles homeicons layergroup      console.log(alllayers);  // here, homeicons have disappeared.      cb(alllayers);    } 

did check if "poitag" excists/spelled correct? provide example of data

if (pois[n].poitag == "home") {   homeicons.push(l.marker(homemarker));  } else {   circles.push(l.circlemarker([pois[n].lat, pois[n].lng], markeroptions, {name: data[i].name})); } 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -