My map lets users draw coordinates that snap to nearest road. I capture the resulting polylines and store them in a fusion table.
Now I want to retrieve these polyline coordinates and display on the map.
When I have the following in a fusion table, it maps correctly:
<LineString><coordinates>-93.2817792892456,37.20134698578519 -93.28178000000001,37.201420000000006 -93.27869000000001,37.2014 -93.27869000000001,37.2014 -93.27813,37.2014</coordinates></LineString>
But unfortunately the Map input is capturing something that is more like this:
<LineString><coordinates>(37.20134698578519,-93.2817792892456),(37.201420000000006,-93.28178000000001),(37.2014,-93.27869000000001),(37.2014,-93.27869000000001),(37.2014,-93.27813)</coordinates></LineString>
My question is whether to solve this issue I need to parse this string so that it fits the acceptable format, or if I am missing something and there is an easier more acceptable way of doing this.
Jsfiddle is here. If you draw a few polylines, you can either click on the ‘clear’ control to get an alert that shows the coordinates, or you can double click to end the polyline drawing and this will bring up an infobox with ‘Location’ field prepolulated with the coordinates that end up in the fusion table.
This is the fusion table. Records like ‘scce’ and ‘scenic’ display correctly on the map. But record like ‘twisty/new format’ does not.
Any insight on this would be highly appreciated. Thank you for looking.
The Google Maps API uses google.maps.LatLng objects. When converted to a string the coordinates are in the order “Latitude, Longitude”.
The KML format uses the opposite order:
(also allows an optional third “height” coordinate)
Change your code to output the coordinates in the correct order and without the parentheses
Change this:
To:
(not tested)