Quantcast
Channel: Parse coordinates out of XML feed - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by geocodezip for Parse coordinates out of XML feed

$
0
0
  1. Get the content of that XML element into a string. Note that with the "cap" namespace you will have to write browser independent code (different browsers treat that differently).

  2. split the string on spaces (""):

    var coordinates = polygonElemStr.split("");
  3. split each set of coordinates on the comma (","), create a google.maps.LatLng from the two numbers and push it onto an array:

    var path = [];for (var i=0; i<coordinates.length; i++) {  var coord = coordinates[i].split(",");  path.push(new google.maps.LatLng(parseFloat(coord[0]),                                   parseFloat(coord[1])));}
  4. use that array of coordinates to create your polygon.

example


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>