# HG changeset patch # User Matti Hamalainen # Date 1394598446 -7200 # Node ID f5aa704b1ddf0a8bc732de45bd74508c01b2a7ae # Parent fc99d2ca34249cdfea7a20611e520eb639ec881d Add "Make a link" feature. diff -r fc99d2ca3424 -r f5aa704b1ddf css/mapstyle1.css --- a/css/mapstyle1.css Wed Mar 12 06:26:35 2014 +0200 +++ b/css/mapstyle1.css Wed Mar 12 06:27:26 2014 +0200 @@ -196,13 +196,15 @@ display: inline-block; } -#headcontent .info { +#headcontent div.controls { position: absolute; right: 280px; width: auto; } -#headcontent a { +#headcontent div.controls a { + background: #600; + padding: 0.5em; color: white; } diff -r fc99d2ca3424 -r f5aa704b1ddf index.php --- a/index.php Wed Mar 12 06:26:35 2014 +0200 +++ b/index.php Wed Mar 12 06:27:26 2014 +0200 @@ -36,6 +36,7 @@

+
Make link
@@ -55,7 +56,6 @@ @@ -66,8 +66,11 @@ - +pmapInitializeMap("; + if (isset($_GET["x"]) && isset($_GET["y"]) && isset($_GET["zoom"])) + echo intval($_GET["x"]).",".intval($_GET["y"]).",".intval($_GET["zoom"]); + echo ");\n"; +?> diff -r fc99d2ca3424 -r f5aa704b1ddf map.js --- a/map.js Wed Mar 12 06:26:35 2014 +0200 +++ b/map.js Wed Mar 12 06:27:26 2014 +0200 @@ -53,7 +53,7 @@ CanvasProjectionOverlay.prototype.onRemove = function(){}; -function pmapInitializeMap() +function pmapInitializeMap(sx, sy, szoom) { // Initialize custom imagemap with our tiles var pmapBatMap = new google.maps.ImageMapType( @@ -96,6 +96,12 @@ pmapInitializeIcons(); pmapInitializeMarkers(); pmapInitializeNav(); + + if (szoom && sx && sy) + { + pmap.setZoom(szoom); + pmap.panTo(pmapMapCoordsToLatLng(new google.maps.Point(sx, sy), 6)); + } } @@ -108,8 +114,7 @@ var tx = Math.round((p.x + 1) / 2.0); var ty = Math.round((p.y + 1) / 2.0); - var cx = tx; - var cy = ty; + var cx, cy; var cont = "Deep Sea"; for (i = 0; i < pmapContinents.length; i++) @@ -124,7 +129,30 @@ } } - document.getElementById("xcoord").innerHTML = cx; - document.getElementById("ycoord").innerHTML = cy; - document.getElementById("continent").innerHTML = cont; + tx += 8192; + ty += 8192; + + var str = "Cursor: "+ + "Global X: "+ tx +", Y: "+ ty +", "+ + "Continent: "+ cont +" "; + + if (cx >= 0 && cy >= 0) + str += "[ Local X: "+ cx +", Y: "+ cy +" ]"; + + document.getElementById("footercontent").innerHTML = str; } + + +function pmapMakeLink() +{ + if (pmap) + { + var p = pmapLatLngToMapCoords(pmap.getCenter(), 6); + var tx = Math.round(p.x) + 8192; + var ty = Math.round(p.y) + 8192; + + str = "http://tnsp.org/gmap2/?x="+ tx +"&y="+ ty +"&zoom="+ pmap.getZoom(); + + window.prompt("Copy to clipboard: Ctrl+C, Enter", str); + } +}