GoogleMaps - centrowanie mapy


(northwest) #1

Witam,

mam mapkę: http://www.scanerwww.pl/abc/floty/index ... ra=FORMULA

Mam na niej 2 rodzaje markerów. Ikonki google i samochodziki. Mapka centruje się względem wszystkich markerów. Chciałbym to zmienić,

i centrować mapkę względem samych samochodzików (ignorując centrowanie innych punktów)...

Mój plik z danymi wygląda tak: http://www.scanerwww.pl/abc/floty/point ... ra=FORMULA

A plik js tak:

var map = null;

var refreshTime = 5000;

var prevData = null;



	function load()

	{

	if (GBrowserIsCompatible())

	{

	map = new GMap2(document.getElementById("map"));

	map.addControl(new GLargeMapControl ());

        map.addControl(new GScaleControl());

        map.addControl(new GMapTypeControl());


        map.enableContinuousZoom();

        map.enableDoubleClickZoom();

        map.enableScrollWheelZoom();

	map.setCenter(new GLatLng(52.173931692568, 18.8525390625),5);

	GEvent.addListener(map, "moveend",function()

	{

	var ctr = map.getCenter();

	$.cookie('svc1', ctr.lat(), { expires: 365 });

	$.cookie('svc2', ctr.lng(), { expires: 365 });

	$.cookie('svz', map.getZoom(), { expires: 365 });

	}

	);

	GEvent.addListener(map, "zoomend",function()

	{

	$.cookie('svz', map.getZoom(), { expires: 365 });


	}

	);

reloadPoints();

	} }


     function addPoints(data)

        {

	if (prevData != data || data == null)

	   {

var bounds = new GLatLngBounds();

		prevData = data;

		eval("points = ("+data+")");

		pointsCount = points.length;

		map.clearOverlays();


var bounds = new GLatLngBounds(); //do autozoomu

  var maxlng =0;

  var maxlat=0; 

  var minlng;

  var minlat;

		for (var i=0; i
		{

            var etykietka = points[i]['etykietka'];

			var point = new GLatLng(points[i]['lat'],points[i]['lng']);

			map.addOverlay(createMarker(point, points[i]['satellite'], points[i]['autko']));

			var label = new ELabel(new GLatLng(points[i]['lat'],points[i]['lng']), "

"+ etykietka +"
", null, new GSize(6,-30), 75); map.addOverlay(label); if (points[i]['coto'] == 'autko'){ if (points[i]['lat'] < minlat){ minlat = points[i]['lat'] } if (points[i]['lat'] > maxlat){ maxlat = points[i]['lat'] } if (points[i]['lng'] < minlng){ minlat = points[i]['lng'] } if (points[i]['lng'] > maxlng){ maxlat = points[i]['lng'] } } lat = minlat + (( maxlat - minlat)/2); lng = minlng + (( maxlng - minlng)/2); //zmiany //map.setCenter(new GLatLng(lat,lng), 5); //var allpoints= new GLatLng(points[i]['lat'],points[i]['lng']); //autozoom var allpoints= new GLatLng(lat,lng); //autozoom bounds.extend(allpoints); } if($.cookie('ruch')=='on') { if($.cookie('test')!=1) { map.setCenter(new GLatLng($.cookie('svc1'),$.cookie('svc2')),parseInt($.cookie('svz'))); $.cookie('test', '', { expires: 365 }); } } if($.cookie('ruch')=='off') { map.setZoom(map.getBoundsZoomLevel(bounds)-1); map.setCenter(bounds.getCenter()); } } } function createMarker(point, satellite, autko) { var icon = new GIcon(); icon.image = autko; icon.iconAnchor = new GPoint(16, 16); icon.infoWindowAnchor = new GPoint(16, 16); var marker = new GMarker(point, icon); marker.value = satellite; GEvent.addListener(marker, "click", function(){ var myHtml = satellite; map.openInfoWindowHtml(point, myHtml); }); return marker; } function reloadPoints() { loadPointData(); setTimeout(reloadPoints,refreshTime); } [/code]

Wiecie może jak to zrobić??

Z góry dzięki za pomoc,

pozdrawiam Northwest