Commits

Cédric Bonhomme committed d190be3

you can now add the center of the map in the URL parameters (latitude and longitude).

Comments (0)

Files changed (1)

 
 form = cgi.FieldStorage()
 address = form.getvalue("address", "photos.cedricbonhomme.org")
+latitude = form.getvalue("latitude", "")
+longitude = form.getvalue("longitude", "")
 
 html = '<html>\n' + \
         '<head>\n\t<meta charset="utf-8" />\n\t<title>Photos</title>\n\t' + \
                                 new OpenLayers.Control.Attribution()]});
                         photos_location = new OpenLayers.Layer.Markers("Photos");
                         map.addLayer(photos_location);
-                        map.addLayer(new OpenLayers.Layer.OSM());
-                        var lonLatCenter = new OpenLayers.LonLat(position.coords.longitude, position.coords.latitude).transform(
-                        new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() )
-                        map.setCenter (lonLatCenter, zoom);\n"""
+                        map.addLayer(new OpenLayers.Layer.OSM());\n"""
+            if "" in (latitude, longitude):
+                """var lonLatCenter = new OpenLayers.LonLat(position.coords.longitude, position.coords.latitude).transform(
+                                               new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() )
+                   map.setCenter (lonLatCenter, zoom);\n"""
+            else:
+                """var lonLatCenter = new OpenLayers.LonLat(%s, %s).transform(
+                                               new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() )
+                   map.setCenter (lonLatCenter, zoom);\n""" % (longitude, latitude)
+
 
             for idx, photo in enumerate(geolocated_photos):
                 try: