Changeset 396
- Timestamp:
- 07/13/06 10:33:29
- Files:
-
- qPloneGoogleMaps/trunk/README.txt (modified) (1 diff)
- qPloneGoogleMaps/trunk/TODO.txt (modified) (1 diff)
- qPloneGoogleMaps/trunk/__init__.py (modified) (1 diff)
- qPloneGoogleMaps/trunk/adapters/__init__.py (added)
- qPloneGoogleMaps/trunk/browser/__init__.py (added)
- qPloneGoogleMaps/trunk/browser/map_view.pt (added)
- qPloneGoogleMaps/trunk/content/Map.py (modified) (6 diffs)
- qPloneGoogleMaps/trunk/content/Marker.py (modified) (2 diffs)
- qPloneGoogleMaps/trunk/content/Overlay.py (modified) (1 diff)
- qPloneGoogleMaps/trunk/field.py (added)
- qPloneGoogleMaps/trunk/interfaces/__init__.py (added)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/edit_js.py (added)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/getCenterZoom.py (added)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_edit.cpt (added)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_edit.cpt.metadata (added)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_view.pt (modified) (3 diffs)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_widget.pt (added)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/maps_markers.py (modified) (5 diffs)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/maps_view.pt (modified) (1 diff)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/marker_view.pt (modified) (1 diff)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/overlay_view.pt (modified) (1 diff)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/portlet_maps.pt (modified) (2 diffs)
- qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/view_js.py (added)
- qPloneGoogleMaps/trunk/validator.py (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneGoogleMaps/trunk/README.txt
r395 r396 1 1 qPloneGoogleMaps 2 3 Authors 4 5 * Myroslav Opyr 6 7 * Vitaliy Podoba 8 qPloneGoogleMaps/trunk/TODO.txt
r395 r396 6 6 # * folder view 7 7 8 * marker functionality 8 # * marker functionality 9 10 # * map field and widget 11 12 # * navigation portlet view (turn on/off overlay functionality) qPloneGoogleMaps/trunk/__init__.py
r395 r396 8 8 9 9 from Products.qPloneGoogleMaps.config import * 10 11 from Products.validation import validation 12 13 from Products.qPloneGoogleMaps.validator import MapFieldValidator 14 validation.register(MapFieldValidator('isLocation')) 10 15 11 16 allow_module('Products.qPloneGoogleMaps.config') qPloneGoogleMaps/trunk/content/Map.py
r395 r396 8 8 from Products.Archetypes.public import * 9 9 10 from Products.ATContentTypes.content.base import ATCTFolder 10 from Products.ATContentTypes.content.base import ATCTFolder, updateActions 11 11 from Products.ATContentTypes.content.schemata import finalizeATCTSchema 12 12 13 from Products.CMFPlone.interfaces.NonStructuralFolder import INonStructuralFolder13 #from Products.CMFPlone.interfaces.NonStructuralFolder import INonStructuralFolder 14 14 15 from Products.validation.validators.RangeValidator import RangeValidator 16 from Products.validation.config import validation 17 from Products.validation import V_REQUIRED 18 15 from Products.qPloneGoogleMaps.field import * 19 16 from Products.qPloneGoogleMaps.config import * 20 21 validation.register(RangeValidator('checkLatitude',22 minval=-90.0, maxval=90.0))23 validation.register(RangeValidator('checkLongitude',24 minval=-180.0, maxval=180.0))25 17 26 18 zoom_vocaburary = range(18) … … 28 20 29 21 MapSchema = ATCTFolder.schema.copy() + Schema(( 22 MapField('location', 23 default=None, 24 required=True, 25 validators=('isLocation',), 26 widget=MapWidget( 27 label='Map Center', 28 label_msgid='label_map_center', 29 description='Here you can choose map center point on the map by mouse clicking', 30 description_msgid='help_map_center', 31 i18n_domain='googlemaps', 32 ) 33 ), 34 35 StringField('auto', 36 vocabulary=('None', 'Zoom', 'Center', 'Full'), 37 default='None', 38 widget=SelectionWidget( 39 label='Auto Control', 40 label_msgid='label_auto_control', 41 description_msgid='help_auto_control', 42 i18n_domain='googlemaps', 43 format = 'radio', 44 ) 45 ), 46 30 47 IntegerField('height', 31 48 default="480", … … 36 53 description_msgid='help_height', 37 54 i18n_domain='googlemaps', 38 )39 ),40 41 FloatField('latitude',42 required=True,43 validators=(('checkLatitude', V_REQUIRED),),44 widget=DecimalWidget(45 label='Center latitude',46 label_msgid='label_center_latitude',47 description_msgid='help_center_latitude',48 i18n_domain='googlemaps',49 size=12,50 )51 ),52 53 FloatField('longitude',54 required=True,55 validators=(('checkLongitude', V_REQUIRED),),56 widget=DecimalWidget(57 label='Center longitude',58 label_msgid='label_center_longitude',59 description_msgid='help_center_longitude',60 i18n_domain='googlemaps',61 size=12,62 55 ) 63 56 ), … … 86 79 87 80 StringField('mapType', 88 vocabulary=('map', 'satellite' ),89 default=' map',81 vocabulary=('map', 'satellite', 'hybrid'), 82 default='hybrid', 90 83 widget=SelectionWidget( 91 84 label='Map Type', … … 138 131 139 132 # Get the standard actions (tabs) 140 #actions = ATCTContent.actions 133 actions = updateActions(ATCTFolder, 134 ({'id' : 'edit', 135 'name' : 'Edit', 136 'action' : 'string:${object_url}/map_edit', 137 'permissions' : (ModifyPortalContent,) 138 }, 139 ) 140 ) 141 141 142 142 #__implements__ = (ATCTFolder.__implements__, INonStructuralFolder) … … 152 152 security.declareProtected(View, 'geoLocation') 153 153 def geoLocation(self): 154 return (self.getLatitude(), self.getLongitude()) 154 """ Return geolocation tuple """ 155 return self.location 155 156 156 157 security.declareProtected(View, 'getOverlayMarkers') qPloneGoogleMaps/trunk/content/Marker.py
r395 r396 10 10 from Products.ATContentTypes.content.document import ATDocumentSchema 11 11 from Products.ATContentTypes.content.document import ATDocument 12 #from Products.ATContentTypes.content.schemata import ATContentTypeSchema13 12 from Products.ATContentTypes.content.schemata import finalizeATCTSchema 14 13 15 #from Products.CMFPlone.interfaces.NonStructuralFolder import INonStructuralFolder 16 17 from Products.validation.validators.RangeValidator import RangeValidator 18 from Products.validation.config import validation 19 from Products.validation import V_REQUIRED 20 14 from Products.qPloneGoogleMaps.field import * 21 15 from Products.qPloneGoogleMaps.config import * 22 16 23 validation.register(RangeValidator('checkLatitude',24 minval=-90.0, maxval=90.0))25 validation.register(RangeValidator('checkLongitude',26 minval=-180.0, maxval=180.0))27 28 17 MarkerSchema = ATDocumentSchema.copy() + Schema(( 29 FloatField('latitude', 18 MapField('location', 19 default=None, 30 20 required=True, 31 validators=(('checkLatitude', V_REQUIRED),), 32 widget=DecimalWidget( 33 label='Latitude', 34 label_msgid='label_latitude', 35 description_msgid='help_latitude', 21 validators=('isLocation',), 22 widget=MapWidget( 23 label='Marker Location', 24 label_msgid='label_marker_center', 25 description='Here you can choose marker location on the map by mouse clicking', 26 description_msgid='help_marker_center', 36 27 i18n_domain='googlemaps', 37 size=12,38 )39 ),40 41 FloatField('longitude',42 required=True,43 validators=(('checkLongitude', V_REQUIRED),),44 widget=DecimalWidget(45 label='Longitude',46 label_msgid='label_longitude',47 description_msgid='help_longitude',48 i18n_domain='googlemaps',49 size=12,50 28 ) 51 29 ), … … 92 70 security.declareProtected(View, 'geoLocation') 93 71 def geoLocation(self): 94 return (self.getLatitude(), self.getLongitude())72 return self.getLocation() 95 73 96 74 registerType(Marker, PROJECTNAME) qPloneGoogleMaps/trunk/content/Overlay.py
r395 r396 69 69 """ Get object or brains with geolocation properties from source object """ 70 70 container = self.getSource() 71 contentsMethod = container.getFolderContents 72 if container.portal_type == 'Topic': contentsMethod = container.queryCatalog 73 return [el for el in contentsMethod() if el.geoLocation] 71 if container and container.portal_type: 72 contentsMethod = container.getFolderContents 73 if container.portal_type == 'Topic': contentsMethod = container.queryCatalog 74 return [el for el in contentsMethod() if el.geoLocation] 75 return [] 74 76 75 77 registerType(Overlay, PROJECTNAME) qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/map_view.pt
r395 r396 9 9 tal:attributes="src string:http://maps.google.com/maps?file=api&v=2&key=${key}"> 10 10 </script> 11 <span tal:replace="structure python:here.maps_markers(longlat=here.getOverlayMarkers(), node='map', controls=here.getMapControl(), loc=here.geoLocation(), typeControls=here.getTypeControl(), overviewControls=here.getOverviewControl(), events=True, maptype=here.getMapType(), color=False, zoom=here.getZoom(), mapevents=True )" />11 <span tal:replace="structure python:here.maps_markers(longlat=here.getOverlayMarkers(), node='map', controls=here.getMapControl(), loc=here.geoLocation(), typeControls=here.getTypeControl(), overviewControls=here.getOverviewControl(), events=True, maptype=here.getMapType(), color=False, zoom=here.getZoom(), mapevents=True, auto=here.getAuto())" /> 12 12 </metal:block> 13 13 </head> … … 32 32 </p> 33 33 34 <!-- gmarker35 <ul>36 <tal:gmarker tal:repeat="marker python: here.objectValues(['GMarker'])">37 <li id="" tal:attributes="id string:marker_link_${repeat/marker/number}">38 <a href="javascript:void(0)" onclick="this.blur()" tal:content="marker/pretty_title_or_id">39 Gmarker title40 </a>41 </li>42 </tal:gmarker>43 </ul>44 45 <tal:gmarker tal:repeat="marker python: here.objectValues(['GMarker'])">46 <div id="" style="display: none;"47 tal:attributes="id string:marker_html_${repeat/marker/number}">48 <div style="width: 290px;">49 <div class="documentActions">50 <a href="" tal:condition="marker/url"51 tal:attributes="href marker/url"52 i18n:translate="" i18n:domain="plone">53 Link54 </a>55 </div>56 57 <h1 class="documentFirstHeading">58 <a href="" tal:content="marker/pretty_title_or_id"59 tal:attributes="href marker/absolute_url">60 Title or id61 </a>62 </h1>63 64 <img src="" style="float: left; margin: 5px;"65 tal:condition="marker/imageurl"66 tal:attributes="src marker/imageurl" />67 68 <div class="documentDescription"69 tal:content="marker/Description"70 tal:condition="marker/Description">71 Description72 </div>73 74 <div class="address"75 tal:content="marker/address"76 tal:condition="marker/address">77 address78 </div>79 80 <div class="phone"81 tal:content="marker/phone"82 tal:condition="marker/phone">83 phone84 </div>85 86 <div style="clear: both;" tal:condition="marker/getText"87 tal:content="structure marker/getText">88 Body Text89 </div>90 91 </div>92 </div>93 </tal:gmarker>-->94 95 34 <div id="map" style="position: relative; height: 480px;" 96 35 tal:define="height here/getHeight" … … 102 41 </body> 103 42 </html> 104 qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/maps_markers.py
r395 r396 5 5 ##bind script=script 6 6 ##bind subpath=traverse_subpath 7 ##parameters= longlat=[], node, controls='nothing', maptype=' G_NORMAL_MAP', overviewControls=None, typeControls=None, events=False, color='default', zoom=6, loc=(37.4419, -122.1419), marker=False, mapevents=None7 ##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' 8 8 ##title= 9 9 ## … … 27 27 28 28 if maptype == 'satellite': maptype = 'G_SATELLITE_MAP' 29 elif maptype == 'map': maptype = 'G_NORMAL_MAP' 30 else: maptype = 'G_HYBRID_MAP' 29 31 30 32 if (not color) and longlat: 31 33 lat = [float(e.geoLocation[0]) for el in longlat.values() for e in el] 32 34 lon = [float(e.geoLocation[1]) for el in longlat.values() for e in el] 33 sMarkers = "\n".join(["""addMarker(%f, %f, "%s", "%s ", "%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 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]) 34 36 elif longlat: 35 37 lat = [float(el.geoLocation[0]) for el in longlat] 36 38 lon = [float(el.geoLocation[1]) for el in longlat] 37 sMarkers = "\n".join(["""addMarker(%f, %f, "%s", "%s ", "%s", "%s");""" % (float(el.geoLocation[0]), float(el.geoLocation[1]), el.Title, el.getURL(), processDesc(el.Description), color) for el in longlat])39 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]) 38 40 39 41 if controls == 'large': sControls += "map.addControl(new GLargeMapControl());" … … 65 67 }; 66 68 GEvent.addListener(map, 'click', listener);""" % sMarkerForm 69 67 70 if events: 68 71 sMarkerEvents = """ 69 72 var f = function(){marker.openInfoWindowHtml(%s, opt);}; 70 73 GEvent.addListener(marker, 'click', f);\n""" % sInfoWindow 71 if not marker and lon and lat: 74 75 if lon and lat and auto != 'None': 72 76 sDefaults = """ 73 map.setCenter(new GLatLng(%f, %f), map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(%f, %f), new GLatLng(%f, %f)))); 74 map.savePosition();""" % ((min(lat)+max(lat))/2, (min(lon)+max(lon))/2, min(lat), min(lon), max(lat), max(lon)) 77 var centerPoint = new GLatLng(%f, %f), 78 autoZoom = map.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(%f, %f), new GLatLng(%f, %f))); 79 """ % ((min(lat)+max(lat))/2, (min(lon)+max(lon))/2, min(lat), min(lon), max(lat), max(lon)) 80 if auto == 'Zoom': sDefaults += """map.setZoom(autoZoom);""" 81 elif auto == 'Center': sDefaults += """map.setCenter(centerPoint);""" 82 elif auto == 'Full': sDefaults += """map.setCenter(centerPoint, autoZoom);""" 83 sDefaults += """map.savePosition();""" 84 85 if not zoom: zoom = 6 75 86 76 87 return """ 77 88 <script type="text/javascript"> 78 89 //<![CDATA[ 90 91 function registerUnloadFunction(func){ 92 if (window.addEventListener) window.addEventListener("unload", func, false); 93 else if (window.attachEvent) window.attachEvent("onunload", func); 94 }; 79 95 80 96 function onLoadMap(){ … … 83 99 var map = new GMap2(document.getElementById('%(node)s')); 84 100 %(controls)s 85 map.setCenter(new GLatLng(%(lt)f, %(ln)f), %(zoom)s, G_HYBRID_MAP)101 map.setCenter(new GLatLng(%(lt)f, %(ln)f), %(zoom)s, %(maptype)s); 86 102 var opt = map.getInfoWindow(); 87 103 opt.maxWidth = 400; … … 107 123 else window.alert("Google maps aren't compatible with current Browser."); 108 124 }; 125 109 126 registerPloneFunction(onLoadMap); 127 registerUnloadFunction(GUnload); 128 110 129 //]]> 111 130 </script> qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/maps_view.pt
r395 r396 10 10 </script> 11 11 <span tal:define="brain python:here.portal_catalog(path='/'.join(here.getPhysicalPath())); 12 longlat python:test(len(brain)==1 and brain[0]. geoLocation, brain, [])"13 tal:replace="structure python:here.maps_markers(longlat, node='map', events=True, controls='large', typeControls=True, overviewControls=True )" />12 longlat python:test(len(brain)==1 and brain[0].portal_type != 'Map' and brain[0].geoLocation, brain, [])" 13 tal:replace="structure python:here.maps_markers(longlat, node='map', events=True, controls='large', typeControls=True, overviewControls=True, zoom=6, loc=longlat[0].geoLocation)" /> 14 14 </metal:block> 15 15 </head> qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/marker_view.pt
r395 r396 9 9 tal:attributes="src string:http://maps.google.com/maps?file=api&v=2&key=${key}"> 10 10 </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, marker=True, color=here.getColor())" />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)" /> 12 12 13 13 </metal:block> qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/overlay_view.pt
r395 r396 9 9 tal:attributes="src string:http://maps.google.com/maps?file=api&v=2&key=${key}"> 10 10 </script> 11 <span tal:replace="structure python:here.maps_markers(here.getMarkers(), node='map', events=True, color=here.getMarkersColor(), loc=here.geoLocation(), controls=here.getMapControl(), typeControls=here.getTypeControl(), overviewControls=here.getOverviewControl(), maptype=here.getMapType(), zoom=here.getZoom())" />11 <span tal:replace="structure python:here.maps_markers(here.getMarkers(), node='map', events=True, color=here.getMarkersColor(), loc=here.geoLocation(), controls=here.getMapControl(), typeControls=here.getTypeControl(), overviewControls=here.getOverviewControl(), maptype=here.getMapType(),)" /> 12 12 </metal:block> 13 13 </head> qPloneGoogleMaps/trunk/skins/qPloneGoogleMaps/portlet_maps.pt
r395 r396 5 5 <div metal:define-macro="portlet" 6 6 tal:define="brain python:here.portal_catalog(path='/'.join(here.getPhysicalPath())); 7 longlat python:test(len(brain)==1 and brain[0]. geoLocation, brain, [])"7 longlat python:test(len(brain)==1 and brain[0].portal_type != 'Map' and brain[0].geoLocation, brain, [])" 8 8 tal:condition="longlat"> 9 9 … … 12 12 tal:attributes="src string:http://maps.google.com/maps?file=api&v=2&key=${key}"> 13 13 </script> 14 <span tal:replace="structure python:here.maps_markers(longlat, 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')" /> 15 15 16 16 <dl class="portlet" id="portlet-maps">
