Commits

Igor Támara committed 244f469

Updated to work with openlayers 2.11, removed dependencies of external js files

Comments (0)

Files changed (1)

 
 #This is a moinmoin plugin : It projects data from OSM through
 #OpenLayers to your moinmoin instance.
-#Please do note that at the moment, there is a javascript function
-#at http://static.slec.net/slecstats/js/map.js
-#if the load increases a lot, we will be moving the js to another
-#place.
+#
 #
 #= Parameter description =
-#[[OSM(4.65514589,-74.109660387,13,http://www.gfc.edu.co/images/marker.png,200,350)]]
+#<<OSM(4.65514589,-74.109660387,13,http://www.gfc.edu.co/images/marker.png,200,350)>>
 #Will project an OSM map using OpenLayers centered at lan,lot (4.65514589,-74.109660387)
 #with 13 zoom a marker provided by http://www.gfc.edu.co/images/marker.png on a
 #200px width 350 height map.
     if len(spl)<2:
     	return "Indique latitud y longitud como mínimo"
     mydict=parseargs(spl)
-    return """<script
-    src="http://static.slec.net/slecstats/js/jquery-latest.min.js"
-    type="text/javascript"></script><script
-    src="http://openlayers.org/api/OpenLayers.js"
-    type="text/javascript"></script><script
-    src="http://openstreetmap.org/openlayers/OpenStreetMap.js"
-    type="text/javascript"></script><script
-    src="http://static.slec.net/slecstats/js/map.js"
-    type="text/javascript"></script><script type="text/javascript">
-    jQuery(document).ready(function () {
-       var d= Array();
-       d[0]={'lat':%(lat)s,'lon':%(lon)s};
-       var map = my_map('map',d,'%(marker)s',%(zoom)s);
-    });
-
-</script>
-   <div style="width: %(width)spx; height: %(height)spx;" id="map"></div>
-   """  % mydict
+    return """<div style="width: %(width)spx; height: %(height)spx;"  id="map"></div>
+  <script src="http://www.openlayers.org/api/2.11/OpenLayers.js"></script>
+  <script>
+    map = new OpenLayers.Map("map");
+    map.addLayer(new OpenLayers.Layer.OSM());
+ 
+    var lonLat = new OpenLayers.LonLat( %(lon)s ,%(lat)s )
+          .transform(
+            new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
+            map.getProjectionObject() // to Spherical Mercator Projection
+          );
+ 
+    var zoom=%(zoom)s;
+    var size = new OpenLayers.Size(21,25);
+    var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
+    var markers = new OpenLayers.Layer.Markers( "Markers" );
+    map.addLayer(markers);
+ 
+    markers.addMarker(new OpenLayers.Marker(lonLat,new OpenLayers.Icon('%(marker)s',size,offset)));
+ 
+    map.setCenter (lonLat, zoom);
+  </script>
+"""  % mydict