diff options
Diffstat (limited to 'chimere/widgets.py')
| -rw-r--r-- | chimere/widgets.py | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/chimere/widgets.py b/chimere/widgets.py index 9877a45..b0ea71d 100644 --- a/chimere/widgets.py +++ b/chimere/widgets.py @@ -86,9 +86,8 @@ class PointChooserWidget(forms.TextInput): "all": settings.OSM_CSS_URLS + \ ["%schimere/css/forms.css" % settings.STATIC_URL,] } - js = settings.OSM_JS_URLS + \ - ["%schimere/js/edit_map.js" % settings.STATIC_URL, - "%schimere/js/base.js" % settings.STATIC_URL,] + js = settings.OSM_JS_URLS + list(settings.JQUERY_JS_URLS) + \ + ["%schimere/js/jquery.chimere.js" % settings.STATIC_URL] def render(self, name, value, attrs=None, area_name=''): ''' @@ -108,9 +107,21 @@ class PointChooserWidget(forms.TextInput): value = None else: value = None - tpl = getMapJS(area_name) - tpl += u'<script src="%schimere/js/edit_map.js"></script>\n' % \ - settings.STATIC_URL + js = """ + var EPSG_DISPLAY_PROJECTION = epsg_display_projection = new OpenLayers.Projection('EPSG:%s'); + var EPSG_PROJECTION = epsg_projection = new OpenLayers.Projection('EPSG:%s'); + var chimere_init_options = {}; + chimere_init_options["map_layers"] = [new OpenLayers.Layer.OSM.Mapnik('Mapnik')]; + chimere_init_options['dynamic_categories'] = false; + chimere_init_options['edition'] = true; + chimere_init_options["checked_categories"] = []; + """ % (settings.CHIMERE_EPSG_DISPLAY_PROJECTION, + settings.CHIMERE_EPSG_PROJECTION) + #TODO: manage area + tpl = u"<script type='text/javascript'><!--\n"\ + u"%s// !--></script>\n" % js + #tpl += u'<script src="%schimere/js/edit_map.js"></script>\n' % \ + # settings.STATIC_URL tpl += u"<div id='map_edit'></div>"\ u"<div id='live_lonlat'>"\ u" <p><label for='live_latitude'>%s</label>"\ @@ -124,11 +135,12 @@ class PointChooserWidget(forms.TextInput): _("Latitude"), value_y, _("Longitude"), value_x, name, name, val) tpl += "<script type='text/javascript'><!--\n" - tpl += "init();\n" + tpl += "$('#map_edit').chimere(chimere_init_options);\n" if value: tpl += u'var mylonlat = new OpenLayers.LonLat(%f,%f);\n'\ - u'putMarker(mylonlat.transform(epsg_display_projection,\n'\ - u' map.getProjectionObject()).clone(), true);\n' % ( + u'$("#map_edit").chimere("putEditMarker", \n'\ + u' mylonlat.transform(EPSG_DISPLAY_PROJECTION, \n'\ + u' EPSG_PROJECTION), true);\n' % ( value_x, value_y) tpl += "// --></script>\n"\ u"<hr class='spacer'/>\n" |
