Changeset 2510

Show
Ignore:
Timestamp:
01/28/10 16:41:54 (7 weeks ago)
Author:
JensDiemer
Message:

OpenStreetMap? plugin: Bugfix if more than one map on the same page (add map name to id).
Add lucidTag example on admin page.

Location:
branches/0.9/pylucid_project
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/media/PyLucid/OpenStreetMap.js

    r2487 r2510  
    44var layer_markers; 
    55 
    6 function drawmap(lang_code, popuptext, lon, lat, zoom, marker_lon, marker_lat, marker_width, marker_height) { 
     6function drawmap(map_id, lang_code, popuptext, lon, lat, zoom, marker_lon, marker_lat, marker_width, marker_height) { 
    77        log("draw OpenStreetMap:"); 
     8        log("map_id:" + map_id); 
    89        log("lang_code:" + lang_code); 
    910        log("popuptext:" + popuptext); 
     
    1415    OpenLayers.Lang.setCode(lang_code); 
    1516         
    16     map = new OpenLayers.Map('map', { 
     17    map = new OpenLayers.Map(map_id, { 
    1718        projection: new OpenLayers.Projection("EPSG:900913"), 
    1819        displayProjection: new OpenLayers.Projection("EPSG:4326"), 
     
    8182} 
    8283 
    83 //~ function getCycleTileURL(bounds) { 
    84    //~ var res = this.map.getResolution(); 
    85    //~ var x = Math.round((bounds.left - this.maxExtent.left) / (res * this.tileSize.w)); 
    86    //~ var y = Math.round((this.maxExtent.top - bounds.top) / (res * this.tileSize.h)); 
    87    //~ var z = this.map.getZoom(); 
    88    //~ var limit = Math.pow(2, z); 
    89  
    90    //~ if (y < 0 || y >= limit) { 
    91      //~ return null; 
    92    //~ } else { 
    93      //~ x = ((x % limit) + limit) % limit; 
    94  
    95      //~ return this.url + z + "/" + x + "/" + y + "." + this.type; 
    96    //~ } 
    97 //~ } 
  • branches/0.9/pylucid_project/pylucid_plugins/OpenStreetMap/admin.py

    r2487 r2510  
    1515""" 
    1616 
     17from django.utils.translation import ugettext_lazy as _ 
     18 
    1719from reversion.admin import VersionAdmin 
    1820 
    19 from pylucid.base_admin import BaseAdmin 
    20 from pylucid_admin.admin_site import pylucid_admin_site 
     21from pylucid_project.apps.pylucid_admin.admin_site import pylucid_admin_site 
    2122 
    22 from OpenStreetMap.models import MapEntry 
     23from pylucid_project.pylucid_plugins.OpenStreetMap.models import MapEntry 
    2324 
    2425 
    25 class MapEntryAdmin(BaseAdmin, VersionAdmin): 
    26     list_display = ("name", "lon", "lat", "marker_text") 
     26class MapEntryAdmin(VersionAdmin): 
     27    def lucidTag_example(self, obj): 
     28        return '{%% lucidTag OpenStreetMap name="%s" %%}' % obj.name 
     29 
     30    lucidTag_example.short_description = _("lucidTag example") 
     31    lucidTag_example.allow_tags = False 
     32 
     33    list_display = ("name", "lucidTag_example", "lon", "lat", "marker_text") 
    2734    list_display_links = ("name",) 
    2835    list_filter = ("createby", "lastupdateby",) 
  • branches/0.9/pylucid_project/pylucid_plugins/OpenStreetMap/templates/OpenStreetMap/OpenStreetMap.html

    r2487 r2510  
    1010{% endextrahead %} 
    1111<div id="map_container"> 
    12     <div id="map" class="{{ map.name }}" style="width: {{ map.width }}px; height: {{ map.height }}px;"> 
     12    <div id="map_{{ map.name }}" class="{{ map.name }}" style="width: {{ map.width }}px; height: {{ map.height }}px;"> 
    1313    <noscript><h2>JavaScript is needed!</h2></noscript> 
    1414    </div> 
     15    {% if perms.OpenStreetMap.change_mapentry %} 
     16    <div class="admin_links"> 
     17        <a href="{% url admin:OpenStreetMap_mapentry_change map.id %}" title="{% trans 'edit in django admin site' %}" class="add_openinwindow">{% trans 'edit this map entry' %}</a> 
     18    </div> 
     19    {% endif %} 
    1520    <a href="http://www.openstreetmap.org/?lat={{ map.lat }}&lon={{ map.lon }}&zoom={{ map.zoom }}" id="osm" class="add_openinwindow">www.openstreetmap.org</a> 
    16     <script type="text/javascript">drawmap("{{ lang_code }}", "{{ map.get_html }}", {{ map.lon }}, {{ map.lat }}, {{ map.zoom }}, {{ map.marker_lon }}, {{ map.marker_lat }}, {{ map.marker_width }}, {{ map.marker_height }});</script> 
     21    <script type="text/javascript">drawmap("map_{{ map.name }}", "{{ lang_code }}", "{{ map.get_html }}", {{ map.lon }}, {{ map.lat }}, {{ map.zoom }}, {{ map.marker_lon }}, {{ map.marker_lat }}, {{ map.marker_width }}, {{ map.marker_height }});</script> 
    1722</div> 
    1823{% endblock %}