I am not sure why you are using LOAD and response.js. It seems
un-necessary. Also I am not sure it is a good idea to put JS in
controllers. Instead I would do:
def index():
return dict()
def map_data():
return response.json([.....])
and have an index.html that includes all the JS you need and the calls
jQuery(function(){
jQuery.getJSON('{{=URL('map_data')}}',function(data_in_json) {
// display the data_in_json in MAP
});
});
On Thursday, 19 February 2015 04:54:58 UTC-6, Serbulent Ocal wrote:
>
>
> I am new in this group.
>
> I am struggling with to put the openlayers java script code to web2py
> controller (test.py) together. My aim is to combine them and I was
> wondering
>
> how to put them together to show the tiles as base and the map on top of
> it?
>
> test.py:
>
> 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()
>
> openlayers (tile.html)
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML>
> <HEAD>
> <TITLE>OpenLayers</TITLE>
> <META content="text/html; charset=windows-1252" http-equiv=Content-Type>
> <script src="http://openlayers.org/api/OpenLayers.js"></script>
> <META name=GENERATOR content="MSHTML 9.00.8112.16540"></HEAD>
> <BODY>
> <DIV style="WIDTH: 100%; HEIGHT: 100%" id=map></DIV>
> <SCRIPT type=text/javascript defer>
> var map = new OpenLayers.Map('map');
> var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
> "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
> var dm_wms = new OpenLayers.Layer.WMS(
> "Canadian Data",
> "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
> {
> layers: "bathymetry,land_fn,park,drain_fn,drainage," +
> "prov_bound,fedlimit,rail,road,popplace",
> transparent: "true",
> format: "image/png"
> },
> {isBaseLayer: false}
> );
> map.addLayers([wms, dm_wms]);
> map.zoomToMaxExtent();
> </SCRIPT>
> </BODY></HTML>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.