You have to explain first what does mean

  jQuery(xml).find("marker").each(function() {

That is not valid JavaScript.






On Dec 22, 8:14 pm, Adrien <[email protected]> wrote:
> Hey,
>
> I'm currently trying to set up a map with automatically generated
> markers. Everything is fine but i just can't get the fitBounds method
> working. Here is a piece of code:
>
>         $.fn.googleMap = function(address, options, zoomV,xml) {
>                   var defaults = {
>                     lat: 44.081996,
>                     long: -123.0286928,
>                     zoom: zoomV,
>                     mapTypeId: google.maps.MapTypeId.ROADMAP,
>                     mapTypeControl: false
>                   };
>
>                   options = $.extend(defaults, options || {});
>
>                   var center = new google.maps.LatLng(options.lat, 
> options.long);
>                   map = new google.maps.Map(this.get(0), defaults);
>
>                   if (xml != '') {
>                           var bounds = new google.maps.LatLngBounds ();
>                                 jQuery(xml).find("marker").each(function() {
>                                          var marker = jQuery(this);
>                                  var name = marker.attr("name");
>                                  var pid = marker.attr("id");
>                                  var address = marker.attr("address");
>                                  ....
>                                  ....
>
>                                  // New point
>                                  var point = new 
> google.maps.LatLng(parseFloat(marker.attr
> ("lat")),parseFloat(marker.attr("lng")));
>                                  //add Marker
>                                  addMarker
> (point,name,address,currency,min,max,map,pid,url);
>
>                                  // Extend bound
>                                  bounds.extend(point);
>                                });
>
>                         // Fit all markers
>                     map.fitBounds(bounds);
>                   console.log(bounds); <--- Result:  ((49.1702,
> -123.18699999999998), (49.3508, -123.093)) $=Object D=Object
>                   }
>                 };
>
> Is something wrong?The bounds looks good, the map center too but zoom
> still not.
> Here is a live example:http://test2.rentfortheholidays.com/gmap.html
>
> Thanks in advance for your help.
>
> Adrien

--

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