On Aug 11, 8:28 pm, Douglas Rhiner <[email protected]> wrote:
> This is my first stab at using XML/AJAX in conjunction with PHP and
> Google Maps and I'm having problems getting "new google.maps.LatLng"
> to get-an-attribute.
>
> As background:
> I use getPosition() to get the Latitude and Longitude of a marker
> location and store this in a MySQL database, in the format (lat,long)
> 38.45768,-120.22345.
> I've used this format for many map scripts, pulling data from MySQL
> databases and php-echoing the output with no problems what so ever.
> By running the php script that generates the XML I'm able to determine
> that the XML is being generated "correctly".
> What seems to be going awry is getting the LatLng to get it's
> attribute.
> Here is the code snippet with what I believe to be the offending code
> spaced out by itself.
>
> downloadUrl("genxml.php", function(data) {
> var xml = data.responseXML;
> var markers =
> xml.documentElement.getElementsByTagName("marker");
> for (var i = 0; i < markers.length; i++) {
> var name = markers[i].getAttribute("name");
> var address = markers[i].getAttribute("address");
>
> var point = new
> google.maps.LatLng(markers[i].getAttribute("latlong"));
the google.maps.LatLng class takes 2 numeric arguments, you are giving
it one string. That won't work (as you have discovered).
You need to change the string into 2 numbers (like the original code
did...)
>
> var html = "<b>" + name + "</b> <br/>" + address;
> var marker = new google.maps.Marker({
> map: map,
> position: point,
> });
> bindInfoWindow(marker, map, infoWindow, html);
> }
> });
>
> I've modified this code from one of the articles in the v3API.
> When the original code.....
>
> var point = new google.maps.LatLng(
> parseFloat(markers[i].getAttribute("lat")),
> parseFloat(markers[i].getAttribute("lng")));
Notice the parseFloat which turns a string into a number...
-- Larry
>
> .... is used, and the genxml.php is pointed to a compatible
> db,everything works fine.
>
> Any assistance / point in the right direction would be greatly
> appreciated!
>
> Links to pages in question:
>
> XML generator to verify good XMLhttp://maps.cerebrateaquarium.com/genxml.php
>
> Map Generator with the offending
> script.http://maps.cerebrateaquarium.com/map_v3.php
--
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.