[Checkins] SVN: keas.googlemap/trunk/ ?\208?\156arker info windows can displayed when page is loaded, not only when marker is clicked.

Dan Korostelev nadako at gmail.com
Thu Nov 6 09:00:06 EST 2008


Log message for revision 92814:
  ?\208?\156arker info windows can displayed when page is loaded, not only when marker is clicked.

Changed:
  U   keas.googlemap/trunk/CHANGES.txt
  U   keas.googlemap/trunk/src/keas/googlemap/browser/README.txt
  U   keas.googlemap/trunk/src/keas/googlemap/browser/__init__.py
  U   keas.googlemap/trunk/src/keas/googlemap/browser/interfaces.py
  U   keas.googlemap/trunk/src/keas/googlemap/browser/keas.googlemap.js
  U   keas.googlemap/trunk/src/keas/googlemap/demo/browser.py
  U   keas.googlemap/trunk/src/keas/googlemap/demo/markers.pt

-=-
Modified: keas.googlemap/trunk/CHANGES.txt
===================================================================
--- keas.googlemap/trunk/CHANGES.txt	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/CHANGES.txt	2008-11-06 14:00:04 UTC (rev 92814)
@@ -16,6 +16,10 @@
   and magically get all the necessary javascript viewlets to use the
   google map.
 
+- Feature: markers has now a popup_on_load attribute that can be set to True
+  to get marker's info window displayed when page is loaded, not only when
+  marker is clicked.
+
 Version 0.5.0 (2008-07-28)
 --------------------------
 

Modified: keas.googlemap/trunk/src/keas/googlemap/browser/README.txt
===================================================================
--- keas.googlemap/trunk/src/keas/googlemap/browser/README.txt	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/src/keas/googlemap/browser/README.txt	2008-11-06 14:00:04 UTC (rev 92814)
@@ -111,12 +111,34 @@
                                             zoom:1,
                                             type:G_NORMAL_MAP,
                                             controls:["GLargeMapControl", "GMapTypeControl"],
-                                            markers:[{"latitude": 37.2..., "html": "\n<h1>My Marker</h1>\n<p>This is my marker</p>\n", "longitude": -23.1...}]});
+                                            markers:[{"popup_on_load": false, "latitude": 37.2..., "html": "\n<h1>My Marker</h1>\n<p>This is my marker</p>\n", "longitude": -23.1...}]});
             };
             $(document).unload( function() {GUnload();} );
             </script>
   <BLANKLINE>
 
+By default, marker's popup appears when marker is clicked, but we can change it to
+get popup apper on page load. Note that with Google maps, only one popup can be
+visible at the same time.
+
+  >>> marker.popup_on_load = True
+  >>> print gmap.render()
+  <div style="width: 500px; height: 400px" id="google-map">
+  Loading Map...
+  </div>
+  <BLANKLINE>
+  <script type="text/javascript">
+            var keas_googlemap_maploader = function(){
+                 keas.googlemap.initialize({id:'google-map',
+                                            zoom:1,
+                                            type:G_NORMAL_MAP,
+                                            controls:["GLargeMapControl", "GMapTypeControl"],
+                                            markers:[{"popup_on_load": true, "latitude": 37.2..., "html": "\n<h1>My Marker</h1>\n<p>This is my marker</p>\n", "longitude": -23.1...}]});
+            };
+            $(document).unload( function() {GUnload();} );
+            </script>
+  <BLANKLINE>
+
 To properly display markers, you will need to include the
 markermanager.js utility script from google.  There is a viewlet that
 renders the appropriate script tag.

Modified: keas.googlemap/trunk/src/keas/googlemap/browser/__init__.py
===================================================================
--- keas.googlemap/trunk/src/keas/googlemap/browser/__init__.py	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/src/keas/googlemap/browser/__init__.py	2008-11-06 14:00:04 UTC (rev 92814)
@@ -52,10 +52,12 @@
 
     geocode = FieldProperty(interfaces.IMarker['geocode'])
     html = FieldProperty(interfaces.IMarker['html'])
+    popup_on_load = FieldProperty(interfaces.IMarker['popup_on_load'])
 
-    def __init__(self, geocode=None, html=u''):
+    def __init__(self, geocode=None, html=u'', popup_on_load=False):
         self.geocode = geocode or Geocode()
         self.html = html
+        self.popup_on_load = popup_on_load
 
     def __repr__(self):
         return '%s(%r, %r)' % (self.__class__.__name__,
@@ -96,7 +98,8 @@
         markerString = json.encode(
             [dict(latitude=marker.geocode.latitude,
                   longitude=marker.geocode.longitude,
-                  html=marker.html)
+                  html=marker.html,
+                  popup_on_load=marker.popup_on_load)
              for marker in self.markers])
         return """
           var keas_googlemap_maploader = function(){

Modified: keas.googlemap/trunk/src/keas/googlemap/browser/interfaces.py
===================================================================
--- keas.googlemap/trunk/src/keas/googlemap/browser/interfaces.py	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/src/keas/googlemap/browser/interfaces.py	2008-11-06 14:00:04 UTC (rev 92814)
@@ -95,6 +95,12 @@
         required=True)
 
     html = zope.schema.Text(
-        title=u'html',
+        title=u'HTML',
         description=u'HTML that goes inside the marker popup.',
         required=False)
+
+    popup_on_load = zope.schema.Bool(
+        title=u"Popup on load",
+        description=u"Show marker popup when page is loaded",
+        default=False,
+        required=True)

Modified: keas.googlemap/trunk/src/keas/googlemap/browser/keas.googlemap.js
===================================================================
--- keas.googlemap/trunk/src/keas/googlemap/browser/keas.googlemap.js	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/src/keas/googlemap/browser/keas.googlemap.js	2008-11-06 14:00:04 UTC (rev 92814)
@@ -8,7 +8,8 @@
           controls: ['GLargeMapControl'],
           markers: [{latitude: 3.1234,
                      longitude: 4.52342,
-                     html: "stuff that appears in the window"}]} //an array of markers.
+                     html: "stuff that appears in the window",
+                     popup_on_mode: false}]} //an array of markers.
         */
         if (GBrowserIsCompatible()) {
             var center;
@@ -41,6 +42,13 @@
             map.setCenter(bounds.getCenter());
 
             mgr.refresh();
+
+            for (var i=0; i < markers.length; i++){
+                var conf = config.markers[i];
+                if (conf.popup_on_load)
+                    markers[i].openInfoWindowHtml(conf.html);
+            }
+
         }
     }
 };
\ No newline at end of file

Modified: keas.googlemap/trunk/src/keas/googlemap/demo/browser.py
===================================================================
--- keas.googlemap/trunk/src/keas/googlemap/demo/browser.py	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/src/keas/googlemap/demo/browser.py	2008-11-06 14:00:04 UTC (rev 92814)
@@ -68,7 +68,7 @@
     template = ViewPageTemplateFile("markers.pt")
 
     ignoreContext = True
-    fields = field.Fields(interfaces.IMarker).select('html')
+    fields = field.Fields(interfaces.IMarker).select('html', 'popup_on_load')
     fields+= field.Fields(zope.schema.TextLine(
         title=u'Query',
         __name__='query',
@@ -83,7 +83,8 @@
     def create(self, data):
         query = geocode.GeocodeQuery(data['query'])
         marker = Marker(geocode=IGeocode(query),
-                        html=data['html'])
+                        html=data['html'],
+                        popup_on_load=data['popup_on_load'])
         return marker
 
     def add(self, obj):

Modified: keas.googlemap/trunk/src/keas/googlemap/demo/markers.pt
===================================================================
--- keas.googlemap/trunk/src/keas/googlemap/demo/markers.pt	2008-11-06 13:44:48 UTC (rev 92813)
+++ keas.googlemap/trunk/src/keas/googlemap/demo/markers.pt	2008-11-06 14:00:04 UTC (rev 92814)
@@ -3,4 +3,7 @@
 <div tal:repeat="marker view/markers">
   <span tal:content="marker/geocode/latitude"/>, <span tal:content="marker/geocode/longitude"/><br />
   <div tal:content="structure marker/html">Body</div> 
-</div>
\ No newline at end of file
+  <div>
+  	(display on load: <tal:block replace="marker/popup_on_load" />)
+  </div> 
+</div>



More information about the Checkins mailing list