1

I have a problem with L.control.layer on this code, the control is added but he put another marker on top of the correct one.

Naturally, I'd like to generate the layers from the results, not adding new ones.

2

You're creating new markers right here:

 overlays[destination] = new L.GeoJSON(null, {

Just don't. Refer to the existing instances instead.

  • I think I don't get it, I changed this with overlays[destination] = geoJsonLayer; and it's still not what's expected. – mmeinert Oct 27 '16 at 8:31
  • 1
    Iterate through the individual markers inside your instance of geoJsonLayer. – IvanSanchez Oct 27 '16 at 9:11
  • I appreciate that you are trying to let me find the answer but I still missing the thing, Here is where I'm blocked now. – mmeinert Oct 27 '16 at 11:16
  • 1
    You're on the right track, but you're still overcomplicating things. Be more aware of the contents of your variables (is that a string? or is that a geojson structure? or is that an instance of L.Marker?). See playground-leaflet.rhcloud.com/safa/1/edit?html,output – IvanSanchez Oct 27 '16 at 12:04
  • Got it, "overcomplicating things" is what I do the best way ;) Thank you for your support. – mmeinert Oct 27 '16 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.