Merged in arrai's viewstate link code
Merge commit 'ffe92f7db84789436f53769df1099cd8a68e6097' into arrai-master Conflicts: template.html
This commit is contained in:
@@ -221,10 +221,37 @@ function initMarkers() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function makeLink() {
|
||||||
|
var a=location.href.substring(0,location.href.lastIndexOf("/")+1)
|
||||||
|
+ "?lat=" + map.getCenter().lat().toFixed(6)
|
||||||
|
+ "&lng=" + map.getCenter().lng().toFixed(6)
|
||||||
|
+ "&zoom=" + map.getZoom();
|
||||||
|
document.getElementById("link").innerHTML = a;
|
||||||
|
}
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
var mapOptions = {zoom: config.defaultZoom,
|
|
||||||
center: new google.maps.LatLng(0.5, 0.5),
|
var query = location.search.substring(1);
|
||||||
|
|
||||||
|
var lat = 0.5;
|
||||||
|
var lng = 0.5;
|
||||||
|
var zoom = config.defaultZoom;
|
||||||
|
var pairs = query.split("&");
|
||||||
|
for (var i=0; i<pairs.length; i++) {
|
||||||
|
// break each pair at the first "=" to obtain the argname and value
|
||||||
|
var pos = pairs[i].indexOf("=");
|
||||||
|
var argname = pairs[i].substring(0,pos).toLowerCase();
|
||||||
|
var value = pairs[i].substring(pos+1).toLowerCase();
|
||||||
|
|
||||||
|
// process each possible argname
|
||||||
|
if (argname == "lat") {lat = parseFloat(value);}
|
||||||
|
if (argname == "lng") {lng = parseFloat(value);}
|
||||||
|
if (argname == "zoom") {zoom = parseInt(value);}
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapOptions = {
|
||||||
|
zoom: zoom,
|
||||||
|
center: new google.maps.LatLng(lat, lng),
|
||||||
navigationControl: true,
|
navigationControl: true,
|
||||||
scaleControl: false,
|
scaleControl: false,
|
||||||
mapTypeControl: false,
|
mapTypeControl: false,
|
||||||
@@ -260,7 +287,15 @@ function initialize() {
|
|||||||
initRegions();
|
initRegions();
|
||||||
drawMapControls();
|
drawMapControls();
|
||||||
|
|
||||||
|
makeLink();
|
||||||
|
|
||||||
|
// Make the link again whenever the map changes
|
||||||
|
google.maps.event.addListener(map, 'zoom_changed', function() {
|
||||||
|
makeLink();
|
||||||
|
});
|
||||||
|
google.maps.event.addListener(map, 'center_changed', function() {
|
||||||
|
makeLink();
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,5 +14,6 @@
|
|||||||
</head>
|
</head>
|
||||||
<body onload="initialize()">
|
<body onload="initialize()">
|
||||||
<div id="mcmap" style="width:100%; height:100%"></div>
|
<div id="mcmap" style="width:100%; height:100%"></div>
|
||||||
|
<div id="link" style="border:1px solid black;background-color:white;color:black;position:absolute;top:5px;right:5px"></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user