changeset 265:e908103cdcd8 gmap2

Change how map initialization arguments are handled.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 Apr 2014 20:52:11 +0300
parents 649c82460b76
children b50a7ab76548
files map.js
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/map.js	Sun Apr 13 16:38:20 2014 +0300
+++ b/map.js	Sun Apr 13 20:52:11 2014 +0300
@@ -93,16 +93,21 @@
   pmapCanvas.setMap(pmap);
 
   google.maps.event.addListener(pmap, "mousemove", pmapCoordinateListener);
-  if (args && args.zoom && args.x && args.y)
+
+  if (typeof(args) == "object")
   {
-    google.maps.event.addDomListener(pmap, "foobar", function()
+    if ("zoom" in args && "x" in args && "y" in args)
     {
-      pmap.setZoom(args.zoom);
-      pmap.panTo(pmapMapCoordsToLatLng(new google.maps.Point(args.x, args.y), 6));
-      var tgtMarker = pmapGetMarkerIndexByCoords(args.x, args.y);
-      if (tgtMarker)
-        pmapMyClick(tgtMarker);
-    });
+      google.maps.event.addDomListener(pmap, "foobar", function()
+      {
+        pmap.setZoom(args.zoom);
+        pmap.panTo(pmapMapCoordsToLatLng(new google.maps.Point(args.x, args.y), 6));
+        var tgtMarker = pmapGetMarkerIndexByCoords(args.x, args.y);
+        if (tgtMarker)
+          pmapMyClick(tgtMarker);
+      });
+    }
+    }
   }
 
   pmapInitializeNav();