Hi folks,
A while back I had some trouble with Polygons nor rendering from one day to
the next.
Uncaught TypeError: Cannot set property 'Lb' of undefined
I've been investigating this on and off for a few weeks now, and I have
found the problem.
It happens when you try to instantiate a new google.maps.Polygon() passing
in {paths: []}. This used to work on 3.3, but on 3.5 (and perhaps 3.4?),
paths cannot be an empty array. The odd thing is that it CAN be an array of
empty arrays!
bad for > 3.4:
new google.maps.Polygon({
paths: []
})
good for all:
new google.maps.Polygon({
paths: [[]]
})
Although this isn't too big an issue, it does seem like a bug since the
documentation for google.maps.PolygonOptions says:
Paths: The ordered sequence of coordinates that designates a closed loop.
Unlike polylines, a polygon may consist of one or more paths. As a result,
the paths property may specify one or more arrays ofLatLng coordinates. Simple
polygons may be defined using a single array of LatLngs. More complex
polygons may specify an array of arrays. Any simple arrays are convered
into
MVCArray<http://code.google.com/apis/maps/documentation/javascript/reference.html#MVCArray>s.
Inserting or removing LatLngs from the MVCArray will automatically update
the polygon on the map.
Here, Yellow is clearly stating ONE OR MORE, but Red steps back and says a
SINGLE ARRAY OF LATLNGS may be used. This is at least inconsistent: If you
are able to use an array of empty arrays for complex polygons, you should be
able to use an empty array for simple polygons imho.
If the desired behavior is to enforce a non-empty Paths array, I suggest
changing the docs sentence to
Paths: The ordered sequence of coordinates that designates a closed loop.
Unlike polylines, a polygon may consist of one or more paths. As a result,
the paths property should specify one or more arrays of LatLng coordinates.
Simple
polygons may be defined using a single array of one or more LatLngs. More
complex polygons may specify an array of arrays. Any simple arrays are
convered into
MVCArray<http://code.google.com/apis/maps/documentation/javascript/reference.html#MVCArray>s.
Inserting or removing LatLngs from the MVCArray will automatically update
the polygon on the map.
I hope I'm not being obtuse here. I really did look for info on this in the
forum, but this issue might be too old, and nothing surfaced.
Thanks,
André.
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/VXhWNllQVWRjWTBK.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.