-
-
Save tazjel/a77a052137e3c317304c7553866378b2 to your computer and use it in GitHub Desktop.
web2py Openstreetmap implementation example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
for url in [ | |
'http://dev.openlayers.org/theme/default/style.css', | |
'http://dev.openlayers.org/examples/style.css', | |
'http://dev.openlayers.org/OpenLayers.js' | |
]: | |
response.files.append(url) | |
def map(): | |
mymap = DIV(_id="map", _class="smallmap") | |
response.js = """var map, layer; | |
function init(){ | |
map = new OpenLayers.Map( 'map'); | |
layer = new OpenLayers.Layer.OSM( "Simple OSM Map"); | |
map.addLayer(layer); | |
map.setCenter( | |
new OpenLayers.LonLat(-71.147, 42.472).transform( | |
new OpenLayers.Projection("EPSG:4326"), | |
map.getProjectionObject() | |
), 12 | |
); | |
}; | |
init(); | |
""" | |
return locals() | |
def index(): | |
mymap = LOAD('test', 'map.load', ajax=True) | |
return locals() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment