Sunday, May 1, 2011

[Google Maps API v2] Re: Getting center and zoom of a map from an XML file

xelawho wrote:
> is it really necessary to have a different zoom level for each marker?
That is not what I am trying to do, all I am trying to do is have the
one zoom level for the entire map in an XML file rather than on the
page itself, because it is a template and I only would like to change
the reference to an XML file.

The code I tried is:
-------------------------------------------
var xmlDoc = GXml.parse(doc);
var markers =
xmlDoc.documentElement.getElementsByTagName("mapstyle");
for (var i = 0; i < markers.length; i++) {
// obtain the attributes for the map
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new GLatLng(lat,lng);
var zoom = markers[i].getAttribute("zoom");
// center and zoom the map
var mapstyle = map.setCenter(point, 5);
--------------------------------------
and that gets the lat and lng from the http://wizz.travel/a/australia/temptest.xml
file, but I cannot get the zoom to work.
I guess it needs to be something like

var mapstyle = map.setCenter(point, "+zoom+");

Can I use setZoom for that? And if so, how? (never seen setZoom before)

--
You received this message because you are subscribed to the Google Groups "Google Maps API V2" group.
To post to this group, send email to google-maps-api@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate