Skip to content
This repository has been archived by the owner on Nov 9, 2023. It is now read-only.

url hash support #392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,19 @@ GMaps.prototype.createPanorama = function(streetview_options) {

return this.panorama;
};
/* Usage: map.getURLHash(); */
GMaps.prototype.getURLHash = function() {
var str = location.hash;
if( str != '' ){
this.setCenter( str.substring((str.indexOf("/")+1), str.lastIndexOf("/")), str.substring((str.lastIndexOf("/")+1), str.length) );
this.setZoom( parseInt( str.substring( 1, str.indexOf( "/" ) ) ) );
}

this.on('bounds_changed', function(){
var hash = '#'+this.getZoom()+'/'+this.getCenter().lat()+'/'+this.getCenter().lng();
location.replace(hash);
});
};

GMaps.createPanorama = function(options) {
var el = getElementById(options.el, options.context);
Expand Down