changeset 224:85ee47035acf gmap2

Open marker info window if specified coordinates hit it exactly.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 14 Mar 2014 12:58:04 +0200
parents b8dfdc61acbd
children fcb19418d28e
files map.js markers.js
diffstat 2 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/map.js	Fri Mar 14 12:57:42 2014 +0200
+++ b/map.js	Fri Mar 14 12:58:04 2014 +0200
@@ -92,16 +92,21 @@
   pmapCanvas.setMap(pmap);
 
   google.maps.event.addListener(pmap, "mousemove", pmapCoordinateListener);
+  if (szoom && sx && sy)
+  {
+    google.maps.event.addDomListener(pmap, "foobar", function()
+    {
+      pmap.setZoom(szoom);
+      pmap.panTo(pmapMapCoordsToLatLng(new google.maps.Point(sx, sy), 6));
+      var mk = pmapGetMarkerIndexByCoords(sx, sy);
+      if (mk)
+        pmapMyClick(mk);
+    });
+  }
 
+  pmapInitializeNav();
   pmapInitializeIcons();
   pmapInitializeMarkers();
-  pmapInitializeNav();
-
-  if (szoom && sx && sy)
-  {
-    pmap.setZoom(szoom);
-    pmap.panTo(pmapMapCoordsToLatLng(new google.maps.Point(sx, sy), 6));
-  }
 }
 
 
--- a/markers.js	Fri Mar 14 12:57:42 2014 +0200
+++ b/markers.js	Fri Mar 14 12:58:04 2014 +0200
@@ -136,6 +136,13 @@
 
 function pmapInitializeMarkers()
 {
+  pmapInfoWindow = new google.maps.InfoWindow;
+
+  google.maps.event.addListener(pmap, 'click', function()
+  {
+    pmapInfoWindow.close();
+  });
+
   pmapMMgr = new MarkerManager(pmap);
   google.maps.event.addListener(pmapMMgr, 'loaded', pmapLoadMarkers);
 }
@@ -144,12 +151,6 @@
 function pmapLoadMarkers()
 {
   pmapMIndex = 0;
-  pmapInfoWindow = new google.maps.InfoWindow;
-
-  google.maps.event.addListener(pmap, 'click', function()
-  {
-    pmapInfoWindow.close();
-  });
 
   //
   // Parse regular markers from JSON
@@ -178,6 +179,7 @@
     //pmapAddMarkers(pmapAreas["fort"],    8, 11);
     pmapMMgr.refresh();
 
+    google.maps.event.trigger(pmap, "foobar");
     document.getElementById("sidecontent").innerHTML = pmapSideBuiltinHTML;
   });