Source

moinmoin-osm / macro / OSM.py

Full commit
# -*- coding: utf-8 -*-
#
#Author : Igor Támara
#Date : 11/09/2008
#Given to the public domain.

#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)]]
#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.
#
# Enjoy

#Working with IE5.5 And above thanks to woakas patch, still working with Firefox and Iceweasel ;)

def parseargs(args):
    mydict={}
    mydict['lat']=args[0]
    mydict['lon']=args[1]
    keys=['lat','lon','zoom,13','marker,http://www.parroquiaemaus.org/themes/danieltheme/imapa.png','width,500','height,400']
    for i in range(2,len(args)):
        spl=keys[i].split(",")
    	mydict[spl[0]]=args[i]
    for i in range(len(args),len(keys)):
        spl=keys[i].split(",")
    	mydict[spl[0]]=spl[1]
    return mydict

def execute(macro,args):
    spl=args.split(",")
    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/2.10/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