Pete,

Thank you for your kind answer and patience with my ignorance of the finer aspects of Javascript!

I have spent several hours trying to work this out and am getting nowhere. I have a time-sensitive project, so I need to ask for more help.

Why doesn't the following work? Is it necessary to specify another page for the return json, or can a script on the same page process it?

Thanks!!!

- Ron


<!DOCTYPE html>
<html>
<head>
<style>img{ height: 100px; float: left; }</style>
<script src="http://code.jquery.com/jquery-latest.min.js";></script>
<script>
$(document).ready(function() {
$.getJSON("http://maps.google.com/maps/api/geocode/json?address=201+W+Capitol+Ave,+Jefferson+City,+MO,+651011&sensor=false";, function(data) {
 parseMarkerList(data); //data = JSON returned
 alert(data);
    });
});
</script>

<script>
function parseMarkerList(data) {
 for (var i=0; i < data.length; i++) {
        var lat = data[i].Latitude; // Where Latitude is the node name
        var lng = data[i].Longitude; // Where Longitude is the node name
        //createMarker(lat, lng);
    }
}
</script>
</head>

<body>
<script>
alert("Lat: " + lat +"Lng: " + lng);
</script>


</body>
</html>


On 5/27/2010 6:23 PM, pete wrote:
Hi there,

Whilst capturing a web service request and parsing it's data is not a
Google Maps API related question, I'll attempt to answer as best as
possible for your current query.

Firstly, using a framework like JQuery makes this task extremely
simple, with their $.getJSON method. For documentation see:
http://api.jquery.com/jQuery.getJSON/

You can then write some code to fetch the feed, and store it in a
"data" variable

$(document).ready(function() {
     $.getJSON("http://localhost/myService.aspx, function(data) {
         parseMarkerList(data); //data = JSON returned
     });
});

Your parseMarkerList(data) function can then loop through the JSON
returned, and pull out nodes such as Latitude, Longitude etc,
something such as:

function parseMarkerList(data) {
     for (var i=0; i<  data.length; i++) {
         var lat = data[i].Latitude; // Where Latitude is the node name
         var lng = data[i].Longitude; // Where Longitudeis the node
name
         createMarker(lat, lng);
     }
}

The createMarker function can then be a simple function that drops
markers on the map, see:
http://code.google.com/apis/maps/documentation/javascript/examples/marker-simple.html

Hope this has helped you.
The key is passing your data object from the request's response, to
the function that will iterate through the feed.
Using this technique you can drop hundreds of markers with no
additional code.

Cheers
Pete


On May 28, 8:22 am, ron1776<[email protected]>  wrote:
I can't find documentation on how to capture the reply from Web
Service Request.

We want to set the json return array to a variable so we can parse the
map data we need to then build the cost to make a map.

Ideas?

- Ron

--

*************************************
Ron Calzone
Director, Missouri First, Inc.
mailto:[email protected]
Web URL http://www.mofirst.org
*************************************

--
You received this message because you are subscribed to the Google Groups "Google 
Maps JavaScript API v3" group.
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.

Reply via email to