marker fails when using variable

35 views
Skip to first unread message

Jeff Maynard

unread,
Nov 27, 2017, 7:32:19 AM11/27/17
to Leaflet
Trying to load a new marker - works fine if I specify the LatLng in numeric form. But when I try to use variables:
L.marker([MapLat,  MapLng], {icon: markerHighlight, zIndexOffset: -200}).addTo(map); (Note MapLat and MapLng work Fien elsewhere so that not the problem)
I get this error:
TypeError: null is not an object (evaluating 't.lat') leaflet.js:5:108163

Grateful for any suggestions/workaround...

Arnie Shore

unread,
Nov 27, 2017, 8:25:11 AM11/27/17
to leafl...@googlegroups.com
A guess:  Attach that step to a DOM ready event?

--

---
You received this message because you are subscribed to the Google Groups "Leaflet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leaflet-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

webm...@ramblers-webs.org.uk

unread,
Nov 27, 2017, 8:30:52 AM11/27/17
to Leaflet
Jeff
the first argument to l.marker is a latlong object which has lat and long properties.
see http://leafletjs.com/reference-1.2.0.html#marker
You have two arguments instead
Chris

Jeff Maynard

unread,
Nov 27, 2017, 8:42:51 AM11/27/17
to Leaflet


Chris
well spotted - solved my problem - many thanks!!!
Reply all
Reply to author
Forward
0 new messages