From GamingWiki
Line 20: | Line 20: | ||
var infowindow; | var infowindow; | ||
var markers = new Array(); | var markers = 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); | ||
}); | }); | ||
− | + | markers[id]["GMarker"] = marker; | |
} | } | ||
/** | /** | ||
Line 81: | Line 80: | ||
*/ | */ | ||
function addZone(lat, lng, corners, title, id) { | function addZone(lat, lng, corners, title, 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 | ||
}); | }); | ||
− | + | // Also add a marker | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | // Also add a marker | ||
addMarkerByLatLng(lat,lng,title,id); | addMarkerByLatLng(lat,lng,title,id); | ||
} | } | ||
Line 107: | Line 98: | ||
*/ | */ | ||
function getMarkerList() { | function getMarkerList() { | ||
− | for ( | + | for ( var key in markers ) { |
− | var marker = markers[ | + | 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) { | ||
− | + | var marker = markers[key]; | |
− | if (typeof | + | if (typeof gMarker !== 'undefined') { |
− | newLatLng = | + | var gMarker = marker["GMarker"]; |
− | + | if (typeof gMarker !== 'undefined') { | |
+ | newLatLng = gMarker.getPosition(); | ||
+ | var zoom = marker['zoom']; | ||
+ | if (typeof zoom !== 'undefined') { | ||
+ | newZoom = zoom; | ||
+ | } | ||
+ | } | ||
} | } | ||
} | } | ||
− | map. | + | map.panTo(newLatLng); |
+ | map.setZoom(newZoom); | ||
} | } | ||
Revision as of 20:21, 26 May 2011