0

Re-Implemented jywarrens live hash updating

This commit is contained in:
CounterPillow
2011-05-11 21:33:24 +02:00
committed by Aaron Griffith
parent 027419fa5f
commit 5803478060

View File

@@ -226,12 +226,22 @@ var overviewer = {
overviewer.collections.mapTypes[i]);
}
/*
// Make the link again whenever the map changes
google.maps.event.addListener(overviewer.map, 'maptypeid_changed', function() {
$('#'+overviewerConfig.CONST.mapDivId).css(
'background-color', overviewer.util.getMapTypeBackgroundColor(
overviewer.map.getMapTypeId()));
});
*/
// Add live hash update listener
google.maps.event.addListener(overviewer.map, 'dragend', function() { overviewer.updateHash(); });
google.maps.event.addListener(overviewer.map, 'zoom_changed', function() { overviewer.updateHash(); });
// Jump to the hash if given
overviewer.initHash();
// We can now set the map to use the 'coordinate' map type
overviewer.map.setMapTypeId(overviewer.util.getDefaultMapTypeId());
},
@@ -858,6 +868,22 @@ var overviewer = {
this.tileSize = tileSize;
}
},
'initHash': function() {
if(window.location.hash.split("/").length > 1) {
overviewer.goToHash();
}
},
'setHash': function(lat, lng, zoom) {
window.location.replace("#/" + lat + "/" + lng + "/" + zoom);
},
'updateHash': function() {
overviewer.setHash(overviewer.map.getCenter().lat(), overviewer.map.getCenter().lng(), overviewer.map.getZoom());
},
'goToHash': function() {
coords = window.location.hash.split("/");
overviewer.map.setCenter(coords[1], coords[2]);
overviewer.map.setZoom(coords[3]);
},
/**
* Stuff that we give to the google maps code instead of using ourselves
* goes in here.