Parse a google maps xml with xPath + javscript



I am a bit confused on how to go about developing an application, using Google maps javascript API + the 'Places' library.


What I want to have: an html page with 2 divs: a. left div: contains the google map + results/markers based on a given location ( I have that already)


b. right div: contains a list of the results with drop-down menus to filter the results on the map, on the left div.


So my questions are: a. The response is already loaded in an object for the map on the left div, as in this example: http://ift.tt/1k9zrSk Do I need to load it again - in order to get this information in XML and parse it in the right div? My xml request is for example: http://ift.tt/1sRp2Tt


Where would I insert this (in the above example code) in order to get the xml response and parse the file/node information in text format on the right div?


b. In the callback function there is a loop that goes through the results:



function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}


Could I use that same loop in order to parse the xml nodes without having to load the xml file again? If yes, the google developers site does not have an example of how to do that. It only lists a few xPath expressions but it does not provide a full complete example from scratch. i.e. how to use xPath to parse the xml file with javascript


c. if we need to have 2 separate responses (the google maps api + the web service), how will these 2 communicate between them then?


Not sure if I got it all wrong here...


thanks, k.


No comments:

Post a Comment