When I create Gmap she needed to establish the center and zoom
Once we've created a map via the GMap2 constructor, we need to initialize it. This initialization is accomplished with use of the map's setCenter () method. The setCenter () method requires a GLatLng coordinate and a zoom level and this method must be sent before any other operations are performed on the map, including setting any other attributes of the map itself.
Because of this route is not positioned at the center - this is an example http://grab.by/4OD6
I should on the basis of the coordinates to get the center?
And get a zoom which displays all objects map?
My code:
var TrainingGMap = Class.create ((
initialize: function (div_id, points, options) (
this.options = Object.extend ((), options)
this.points = points;
this.map = new GMap2 (document.getElementById (div_id));
this.map.setCenter (new GLatLng (this.points [0]. lan, this.points [0]. lon), 12);
this.map.setUIToDefault ();
this.set_route ();
)
set_route: function () (
var line = new Array ();
for (var i = 0; i <this.points.length; i + +) (
line [i] = new GLatLng (this.points [i]. lat, this.points [i]. lon);
)
var polyline = new GPolyline (line, "# aa0000", 5);
this.map.addOverlay (polyline);
)
));