Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var munzMapButton = document.createElement( 'img' );
- munzMapButton.id = 'gotoMapBtn';
- munzMapButton.class = 'btn';
- munzMapButton.title = 'View location on Munzee Map and copy to clipboard.';
- munzMapButton.src = 'https://yt3.ggpht.com/-uzybXB9pgSg/AAAAAAAAAAI/AAAAAAAAAAA/JGU1V_Fn4Tg/s68-c-k-no-mo-rj-c0xffffff/photo.jpg';
- munzMapButton.style = 'width: 48px; height: 48px; border: 1px solid #000000; margin: 2px; cursor: pointer;';
- var munzMapNavigate = document.createElement( 'a' );
- munzMapNavigate.id = 'gotoMap';
- munzMapNavigate.appendChild( munzMapButton );
- document.getElementById( 'toolbox' ).prepend( munzMapNavigate );
- var loadGeoHash = document.createElement( 'script' );
- loadGeoHash.src = 'https://www.munzee.com/javascript/map/geohash.js';
- loadGeoHash.type = 'text/javascript';
- document.getElementsByTagName( 'head' )[ 0 ].appendChild( loadGeoHash );
- var rawScript = document.createElement( 'script' );
- rawScript.type = 'text/javascript';
- rawScript.innerText = 'document.getElementById( "gotoMap" ).addEventListener( "mouseover", function(){' +
- 'var strMapZoom = parseFloat( map._zoom - 1 );' +
- 'if ( strMapZoom === parseInt( strMapZoom ) ) { strMapZoom = strMapZoom.toFixed( 1 ); }' +
- 'var strMunzMap = "https://www.munzee.com/map/" + geohash.encode( map.getCenter().lat, map.getCenter().lng, 9 ) + "/" + strMapZoom;' +
- 'document.getElementById( "gotoMap" ).href = strMunzMap;' +
- // 'console.log("Set href to: %o",document.getElementById( "gotoMap" ).href)' +
- ';} );' +
- 'document.getElementById( "gotoMapBtn" ).addEventListener( "click", function( e ){' +
- 'var strMapZoom = parseFloat( map._zoom - 1 );' +
- 'if ( strMapZoom === parseInt( strMapZoom ) ) { strMapZoom = strMapZoom.toFixed( 1 ); }' +
- 'var strMunzMap = "https://www.munzee.com/map/" + geohash.encode( map.getCenter().lat, map.getCenter().lng, 9 ) + "/" + strMapZoom;' +
- 'var el = document.createElement( "textarea" );' +
- 'el.value = strMunzMap;' +
- 'el.setAttribute( "readonly", "" );' +
- 'el.style = { display: "none" };' +
- 'document.body.appendChild( el );' +
- 'el.select();' +
- 'document.execCommand( "copy" );' +
- 'document.body.removeChild( el );' +
- // 'console.log("if ( %o )...: %o", e.ctrlKey,e);' +
- 'if ( !e.ctrlKey ) {' +
- 'e.preventDefault();' +
- 'alert( "Permalink <" + strMunzMap + "> copied to your clipboard!\\n\\n(Please [CTRL]-[Click] if you want to open map in new tab.)" );' +
- '} else { alert( "Permalink copied to your clipboard!" ); }' +
- '} );';
- document.getElementsByTagName( 'head' )[ 0 ].appendChild( rawScript );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement