Hi Manuele and other members, I ´m not a programmer, I come from the Human Sciences, but I´m mounting my social project in http://redhumus.org . I have a lot of issues yet.
I have created the plugin_map in my application to manage gpx tracks from openstreetmaps. The deal is create an application that lets people upload a gpx track, visualize it ina a teble and in a openlayer from OpenStreetMaps. To begin: I have a simple example here, moving the original simple exercise ( http://redhumus.org/mapas/memoria/comunicacioneschilapastrackmap.html) to web2py in https://redhumus.org:8000/redhumus/plugin_mapas/mapa But I´m experiencing problems with it. I would appreciate your help and from anyone interested in participate supporting me in this new project named "ReDHumus" because I´m alone and the process is too slow. Thanks a lot. *My Code:* *In controllers/plugin_mapas.py :* # coding: utf8 def mapa(): return dict() *In views/plugin_mapas/mapa.html : ( I have commented your code because I didn´t got how to set map height) * *{{# here I load the necessary openlayers library and style sheets start = 0 for idx,source in enumerate(( 'openlayers/OpenLayers.js', 'openlayers/OpenStreetMap.js', 'OpenLayers-2.11/style.css', )): # response.files.insert(start+idx,URL(request.application,'static',source)) response.files.append(URL(request.application,'static',source))pass}} <!-- <script type="text/javascript"><!--function () { var map, layer; map = new OpenLayers.Map('map'); layer = new OpenLayers.Layer.OSM( "Simple OSM Map"); map.addLayer(layer); map.setCenter( new OpenLayers.LonLat(9.147, -72.472).transform( new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject() ), 12 ); }</script> --> <script type="text/javascript"> // Start position for the map (hardcoded here for simplicity, // but maybe you want to get this from the URL params) var lat=4.83091 var lon=-72.696624 var zoom=12 function init() { var map; //complex object of type OpenLayers.Map map = new OpenLayers.Map ("map", { controls:[ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Attribution()], // maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), //maxResolution: 156543.0399, //numZoomLevels: 13, //units: 'm', //projection: new OpenLayers.Projection("EPSG:900913"), //displayProjection: new OpenLayers.Projection("EPSG:4326") } ); // Define the map layer // Here we use a predefined layer that will be kept up to date with URL changes layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik"); map.addLayer(layerMapnik); layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap"); map.addLayer(layerCycleMap); layerMarkers = new OpenLayers.Layer.Markers("Markers"); map.addLayer(layerMarkers); // Add the Layer with the GPX Track var abril18lgpx = new OpenLayers.Layer.Vector("Abril 18", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-18_082438.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "green", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril23lgpx = new OpenLayers.Layer.Vector("Abril 23", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-23_070052.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "blue", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril24lgpx = new OpenLayers.Layer.Vector("Abril 24", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-24_071627.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "red", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril21lgpx = new OpenLayers.Layer.Vector("Abril 21", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-21_151923_001", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "blue", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril258amlgpx = new OpenLayers.Layer.Vector("Abril 25 8am", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-25_082118.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "yellow", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril251pmlgpx = new OpenLayers.Layer.Vector("Abril 25 1pm", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-25_130838.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "grey", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril253pmlgpx = new OpenLayers.Layer.Vector("Abril 25 3pm", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-25_153806.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "magenta", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril268amlgpx = new OpenLayers.Layer.Vector("Abril 26 8am", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-26_080726.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "cyan", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); // Add the Layer with the GPX Track var abril265pmlgpx = new OpenLayers.Layer.Vector("Abril 26 5pm", { strategies: [new OpenLayers.Strategy.Fixed()], protocol: new OpenLayers.Protocol.HTTP({ url: "tracks/2013-04-26_170826.gpx", format: new OpenLayers.Format.GPX() }), style: {strokeColor: "black", strokeWidth: 5, strokeOpacity: 0.5}, projection: new OpenLayers.Projection("EPSG:4326") }); map.addLayer(abril18lgpx); map.addLayer(abril21lgpx); map.addLayer(abril23lgpx); map.addLayer(abril24lgpx); map.addLayer(abril258amlgpx); map.addLayer(abril251pmlgpx); map.addLayer(abril253pmlgpx); map.addLayer(abril268amlgpx); map.addLayer(abril265pmlgpx); var size = new OpenLayers.Size(21, 25); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon('http://www.openstreetmap.org/openlayers/img/marker.png',size,offset); layerMarkers.addMarker(new OpenLayers.Marker(lonLat,icon)); } </script> {{extend 'layout.html'}} <!-- define a DIV into which the map will appear. Make it take up the whole window --> <div style="height:100%" id="map" class="smallmap"></div> <script>init();</script> {{=BEAUTIFY(response._vars)}} * Salutes from Colombia El sábado, 18 de febrero de 2012 16:33:24 UTC-5, Manuele escribió: > > Il 18/02/2012 22:16, Manuele Pesenti ha scritto: > > hello Antony, > > thanks for your replay... I've just tryed your solution but without > > success... do I have to explicity call the function after the > > definition you suggest? jQuery lib is loaded in the page... > > > > cheers > > > > Manuele > I beg your pardon... the page was white because the map had no height > set :-( > > M. > -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.