When I create Gmap she needed to establish the center and zoom

Because of this route is not positioned at the center - this is an
example http://grab.by/4OD6

How get a zoom which displays my polyline objects map?

My code:

var TrainingGMap = Class.create({
  initialize: function(div_id, points, options) {
    this.options = Object.extend({}, options)
    this.points  = points;
    var latlng = new google.maps.LatLng(this.points[0].lan,
this.points[0].lon);
    this.map = new google.maps.Map(document.getElementById(div_id), {
      zoom: 12,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var line = new Array();
    for (var i = 0; i < this.points.length; i++) {
      line[i] = new google.maps.LatLng(this.points[i].lan,
this.points[i].lon);
    }

    var polyline = new google.maps.Polyline({
        path: line,
        strokeColor: "#aa0000",
        strokeOpacity: 1.0,
        strokeWeight: 5
    });

    polyline.setMap(this.map);
    var polylineBounds = new google.maps.LatLngBounds(line.first(),
line.last());
    this.map.setCenter(polylineBounds.getCenter());
  }
});

-- 
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