Changeset 403

Show
Ignore:
Timestamp:
07/14/06 13:08:34 (4 years ago)
Author:
piv
Message:

added overlay switching functionality

Location:
qPloneGoogleMaps/trunk
Files:
2 added
7 modified

Legend:

Unmodified
Added
Removed
  • qPloneGoogleMaps/trunk/Extensions/Install.py

    r370 r403  
    9090            right_slots = list(right_slots) + [slot,] 
    9191            self.right_slots = right_slots 
    92             out.write('Added maps portlet to right_slots property.\n') 
     92            out.write('Added %s portlet to right_slots property.\n' % slot) 
    9393 
    9494def removePortlet(self, out, slot): 
     
    9999        right_slots.remove(slot) 
    100100        self.right_slots = right_slots 
    101         out.write('Removed maps portlet from right slots property.\n') 
     101        out.write('Removed %s portlet from right slots property.\n' % slot) 
    102102 
    103103def setupSkin(self, out, skinFolder): 
     
    153153    installContentTypes(self, out) 
    154154 
    155     # add portlet to right slot 
     155    # add portlets to right slot 
    156156    addPortlet(self, out, 'here/portlet_maps/macros/portlet') 
     157    addPortlet(self, out, 'here/portlet_overlays/macros/portlet') 
    157158 
    158159    # add map view template to the topic portal type 
     
    174175    removeCatalogColumn(self, 'geoLocation', out) 
    175176 
    176     # remove portlet from right slot 
     177    # remove portlets from right slot 
    177178    removePortlet(self, out, 'here/portlet_maps/macros/portlet') 
     179    removePortlet(self, out, 'here/portlet_overlays/macros/portlet') 
    178180 
    179181    # remove map view template from the topic portal type 
  • qPloneGoogleMaps/trunk/content/Map.py

    r396 r403  
    163163            if el.portal_type == 'Overlay': 
    164164                color = el.getMarkersColor() 
    165                 markers = el.getMarkers() 
     165                markers =  el.getMarkers() 
    166166            elif el.portal_type == 'Marker': 
    167167                color = el.getColor() 
    168168                markers = list(catalog(path='/'.join(el.getPhysicalPath()))) 
    169169            else: continue 
    170             result[color] = result.get(color, []) + markers 
     170            result[(el.getId(),color)] = result.get(el.getId(), []) + markers 
    171171        return result 
    172172 
  • qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_view.pt

    r396 r403  
    2222    </div> 
    2323 
     24    <h1 tal:content="here/pretty_title_or_id" class="documentFirstHeading"> 
     25      Title or id 
     26    </h1> 
     27 
    2428    <div metal:use-macro="here/document_byline/macros/byline"> 
    2529      Get the byline - contains details about author and modification date. 
  • qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_widget.pt

    r396 r403  
    3939                     tal:attributes="tabindex tabindex/next"></div> 
    4040            <tal:block define="coord python:test(latitude and longitude, (latitude, longitude), None); 
    41                                longlat python:test(here.getOverlayMarkers, here.getOverlayMarkers(), []);" 
     41                               longlat here/getOverlayMarkers|python:[]" 
    4242                       replace="structure python:context.edit_js(coord, longlat)" /> 
    4343        </metal:fill> 
  • qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/maps_markers.py

    r396 r403  
    55##bind script=script 
    66##bind subpath=traverse_subpath 
    7 ##parameters= longlat=[], node, controls='nothing', maptype='hybrid', overviewControls=None, typeControls=None, events=False, color='default', zoom=None, loc=(37.4419, -122.1419), mapevents=None, auto='None' 
     7##parameters= longlat=[], node, controls='nothing', maptype='hybrid', overviewControls=None, typeControls=None, events=False, color='default', zoom=None, loc=(37.4419, -122.1419), mapevents=None, auto='Full' 
    88##title= 
    99## 
     
    3333    lat = [float(e.geoLocation[0]) for el in longlat.values() for e in el] 
    3434    lon = [float(e.geoLocation[1]) for el in longlat.values() for e in el] 
    35     sMarkers = "\n".join(["""addMarker(%f, %f, "%s", "%s/view", "%s", "%s");""" % (float(e.geoLocation[0]), float(e.geoLocation[1]), e.Title, e.getURL(), processDesc(e.Description), el) for el, value in longlat.items() for e in value]) 
     35    #raise str(longlat.items()[0][1].items()[0][1]) 
     36#{id:{color:[markers]}} 
     37    sMarkers = "\n".join([""" 
     38addMarker(%(lt)f, %(lg)f, "%(title)s", "%(url)s/view", "%(desc)s", "%(c)s"); 
     39typeof(overLays["%(id)s"])=='undefined'?overLays["%(id)s"]=[]:''; 
     40overLays["%(id)s"].push([%(lt)f, %(lg)f, "%(title)s", "%(url)s/view", "%(desc)s", "%(c)s"]); 
     41""" % {'lt':float(e.geoLocation[0]), 
     42       'lg':float(e.geoLocation[1]), 
     43       'title':e.Title, 
     44       'url':e.getURL(), 
     45       'desc':processDesc(e.Description), 
     46       'c':el[1], 
     47       'id':el[0]} for el, value in longlat.items() for e in value]) 
    3648elif longlat: 
    3749    lat = [float(el.geoLocation[0]) for el in longlat] 
     
    3951    sMarkers = "\n".join(["""addMarker(%f, %f, "%s", "%s/view", "%s", "%s");""" % (float(el.geoLocation[0]), float(el.geoLocation[1]), el.Title, el.getURL(), processDesc(el.Description), color) for el in longlat]) 
    4052 
    41 if controls == 'large': sControls += "map.addControl(new GLargeMapControl());" 
    42 elif controls == 'small': sControls += "map.addControl(new GSmallMapControl());" 
    43 if typeControls: sControls += "map.addControl(new GMapTypeControl());" 
     53if controls == 'large': sControls += "map.addControl(new GLargeMapControl());\n" 
     54elif controls == 'small': sControls += "map.addControl(new GSmallMapControl());\n" 
     55if typeControls: sControls += "map.addControl(new GMapTypeControl());\n" 
    4456if overviewControls: sControls += "map.addControl(new GOverviewMapControl());\n" 
    4557 
     
    89101//<![CDATA[ 
    90102 
    91 function registerUnloadFunction(func){ 
    92   if (window.addEventListener) window.addEventListener("unload", func, false); 
    93   else if (window.attachEvent) window.attachEvent("onunload", func); 
     103function addEvent(el, evt, func){ 
     104  if (el.addEventListener) el.addEventListener(evt, func, false); 
     105  else if (el.attachEvent) el.attachEvent("on"+evt, func); 
    94106}; 
    95107 
     
    97109  if (GBrowserIsCompatible()) { 
    98110 
    99     var map = new GMap2(document.getElementById('%(node)s')); 
     111    map = new GMap2(document.getElementById('%(node)s')); 
    100112    %(controls)s 
    101113    map.setCenter(new GLatLng(%(lt)f, %(ln)f), %(zoom)s, %(maptype)s); 
    102     var opt = map.getInfoWindow(); 
     114    var opt = map.getInfoWindow(), overLays = {}; 
    103115    opt.maxWidth = 400; 
    104116 
     
    116128      map.addOverlay(marker); 
    117129      %(event)s 
    118     } 
     130    }; 
    119131    %(mapevents)s 
    120132    %(markers)s 
    121133    %(defaults)s 
     134 
     135    if (typeof(getData) == 'function') { 
     136        var over_obj = getData(); 
     137        if (over_obj) { 
     138            for (var i=0; i < over_obj['boxes'].length; i++) addEvent(over_obj['boxes'][i], 'click', 
     139                function (){ 
     140                    map.clearOverlays(); 
     141                    var bs = getData(); 
     142                    for (id in bs) { 
     143                        if (bs[id] == true) { 
     144                            for (var j=0; j < overLays[id].length; j++) { 
     145                                var opts = overLays[id][j]; 
     146                                //alert(opts); 
     147                                addMarker(opts[0], opts[1], opts[2], opts[3], opts[4], opts[5]); 
     148                            }; 
     149                        } 
     150                    }; 
     151                }); 
     152        } 
     153    }; 
     154 
    122155  } 
    123156  else window.alert("Google maps aren't compatible with current Browser."); 
    124157}; 
    125158 
    126 registerPloneFunction(onLoadMap); 
    127 registerUnloadFunction(GUnload); 
     159addEvent(window, 'load', onLoadMap); 
     160addEvent(window, 'unload', GUnload); 
    128161 
    129162//]]> 
  • qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/marker_view.pt

    r396 r403  
    99            tal:attributes="src string:http://maps.google.com/maps?file=api&amp;v=2&amp;key=${key}"> 
    1010    </script> 
    11     <span tal:replace="structure python:here.maps_markers(here.portal_catalog(path='/'.join(here.getPhysicalPath())), node='map', events=True, loc=here.geoLocation(), controls='large', typeControls=True, overviewControls=True, color=here.getColor(), zoom=6)" /> 
     11    <span tal:replace="structure python:here.maps_markers(here.portal_catalog(path='/'.join(here.getPhysicalPath())), node='map', events=True, loc=here.geoLocation(), controls='large', typeControls=True, overviewControls=True, color=here.getColor(), zoom=6, auto='None')" /> 
    1212 
    1313  </metal:block> 
  • qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/portlet_maps.pt

    r396 r403  
    1212            tal:attributes="src string:http://maps.google.com/maps?file=api&amp;v=2&amp;key=${key}"> 
    1313    </script> 
    14     <span tal:replace="structure python:here.maps_markers(longlat, loc=longlat[0].geoLocation, zoom=5, node='portlet_map', controls='small')" /> 
     14    <span tal:replace="structure python:here.maps_markers(longlat, loc=longlat[0].geoLocation, zoom=5, node='portlet_map', controls='small', auto='None')" /> 
    1515 
    1616<dl class="portlet" id="portlet-maps">