Skip to content

Instantly share code, notes, and snippets.

@tazjel
Forked from manuelep/test.py
Created June 23, 2017 14:49
Show Gist options
  • Save tazjel/a77a052137e3c317304c7553866378b2 to your computer and use it in GitHub Desktop.
Save tazjel/a77a052137e3c317304c7553866378b2 to your computer and use it in GitHub Desktop.
web2py Openstreetmap implementation example
# -*- 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