Commits

Ralph Bean committed 3d3def9

Added zoom and center params

  • Participants
  • Parent commits ecc1ce9

Comments (0)

Files changed (3)

tw2/polymaps/static/custom/js/tw2.polymaps.js

 
 var po = org.polymaps;
 
-function setupPolymap(args, api_key, tileset_id)
+function setupPolymap(args, api_key, tileset_id,
+        center_latlon, center_range,
+        zoom, zoom_range)
 {
         var map = po.map();
         map.container(
         .url(po.url("http://{S}tile.cloudmade.com/" + api_key
                 + "/" + tileset_id + "/256/{Z}/{X}/{Y}.png")
                 .hosts(["a.", "b.", "c.", ""])));
+
+        if ( center_latlon ) { map.center(center_latlon); }
+        if ( center_range ) { map.centerRange(center_range); }
+        if ( zoom ) { map.zoom(zoom); }
+        if ( zoom_range ) { map.zoomRange(zoom_range); }
+
         return map;
 }
 

tw2/polymaps/templates/polymap.mak

 </div>
 <script type="text/javascript">
 	var map = setupPolymap(${w.j('attrs')}, ${w.j('cloudmade_api_key')},
-	                       ${w.j('_tileset_id')});
+	                       ${w.j('_tileset_id')},
+						   ${w.j('center_latlon')}, ${w.j('center_range')},
+						   ${w.j('zoom')}, ${w.j('zoom_range')});
 	map = setupPolymapControls(map,
 	            ${w.j('arrow')}, ${w.j('compass')}, ${w.j('dblclick')},
 				${w.j('drag')}, ${w.j('grid')}, ${w.j('hash')},

tw2/polymaps/widgets.py

         default='pale-dawn')
     _tileset_id = twc.Variable("Cloudmade tileset id")
 
+    center_latlon = twc.Param(
+        """A dict specifying the center of the map.  The dict should be of the
+        following form::
+
+            {'lat': -85.05112, 'lon' : -120.0}
+
+        This is typically used in conjunction with the `zoom` parameter.
+        """, default=None)
+
+    center_range = twc.Param(
+        """A list of dicts specifying the south-west and north-east corners of
+        *constraints* on the range.  The value should be of the following form::
+
+            [{'lat': -85.05112, 'lon': -120.0},
+             {'lat': +85.05212, 'lon': +120.0}]
+
+        """, default=None)
+
+    zoom = twc.Param("A nonnegative number indicating the `zoom`", default=None)
+    zoom_range = twc.Param("A two-element list constrainting `zoom`",
+                           default=None)
+
+
     arrow = twc.Param(
         """Constructs an arrow control with default settings. The arrow control
         provides key listeners for the arrow keys for panning, and the plus and