From GamingWiki
Jump to: navigation, search
Line 20: Line 20:
 
var infowindow;
 
var infowindow;
 
var markers = new Array();
 
var markers = new Array();
var GMarkers = new Array();
 
 
var defaultLatLng = new google.maps.LatLng(43.243702,-79.889145);
 
var defaultLatLng = new google.maps.LatLng(43.243702,-79.889145);
 
var defaultZoom  = 12;
 
var defaultZoom  = 12;
Line 51: Line 50:
 
infowindow.open(map,marker);  
 
infowindow.open(map,marker);  
 
});
 
});
GMarkers[id] = marker;
+
markers[id]["GMarker"] = marker;
 
}
 
}
 
/**
 
/**
Line 81: Line 80:
 
  */
 
  */
 
function addZone(lat, lng, corners, title, id) {
 
function addZone(lat, lng, corners, title, id) {
//var descId = 'desc'+id;
 
 
// Draw zone
 
// Draw zone
 
var zone = new google.maps.Polygon({
 
var zone = new google.maps.Polygon({
Line 92: Line 90:
 
map:          map
 
map:          map
 
});
 
});
//zone.setMap(map);
+
// Also add a marker
//var marker = new google.maps.Marker({position:latlng, map: map, title:title});
 
//google.maps.event.addListener(zone, "click", function() {
 
// infowindow.setContent(document.getElementById(descId).innerHTML);
 
// infowindow.open(map,zone);
 
// });
 
//GMarkers[id] = zone;
 
// Also add a marker?
 
 
addMarkerByLatLng(lat,lng,title,id);
 
addMarkerByLatLng(lat,lng,title,id);
 
}
 
}
Line 107: Line 98:
 
  */
 
  */
 
function getMarkerList() {
 
function getMarkerList() {
for ( i = 0; i < markers.length; i++ ) {
+
for ( var key in markers ) {
var marker = markers[i];
+
var marker = markers[key];
 
// Figure out what sort of information we have here.
 
// Figure out what sort of information we have here.
 
if (marker['corners'] != '') {
 
if (marker['corners'] != '') {
Line 132: Line 123:
  
 
/**
 
/**
 
 
  * Centre on a particular location on the map, if it exists
 
  * Centre on a particular location on the map, if it exists
 
  */
 
  */
 
function recentre(key) {
 
function recentre(key) {
 
var newLatLng = defaultLatLng;
 
var newLatLng = defaultLatLng;
 +
var newZoom  = defaultZoom;
 
if (key) {
 
if (key) {
aMarker = GMarkers[key];
+
var marker = markers[key];
if (typeof aMarker !== 'undefined') {
+
if (typeof gMarker !== 'undefined') {
newLatLng = aMarker.getPosition();
+
var gMarker = marker["GMarker"];
//aMarker.click();
+
if (typeof gMarker !== 'undefined') {
 +
newLatLng = gMarker.getPosition();
 +
var zoom = marker['zoom'];
 +
if (typeof zoom !== 'undefined') {
 +
newZoom = zoom;
 +
}
 +
}
 
}
 
}
 
}
 
}
map.setCenter(newLatLng);
+
map.panTo(newLatLng);
 +
map.setZoom(newZoom);
 
}
 
}
  

Revision as of 20:21, 26 May 2011