]> git.parisson.com Git - telemeta.git/commitdiff
begin maps API v2 to v3 migration mapsv3
authorGuillaume Pellerin <yomguy@parisson.com>
Fri, 29 Nov 2013 10:06:19 +0000 (11:06 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Fri, 29 Nov 2013 10:06:19 +0000 (11:06 +0100)
example/sandbox/settings.py
telemeta/static/telemeta/js/resourcemap.js
telemeta/templates/telemeta/geo_continents.html

index 0a38030063433b590fea2e4860526349361dd159..bce1923389422ab3bfc6026d2eb2152dd8d2d22c 100644 (file)
@@ -142,7 +142,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
 TELEMETA_ORGANIZATION = 'Parisson'
 TELEMETA_SUBJECTS = ('test', 'telemeta', 'sandbox')
 TELEMETA_DESCRIPTION = "Telemeta TEST sandbox"
-TELEMETA_GMAP_KEY = 'ABQIAAAArg7eSfnfTkBRma8glnGrlxRVbMrhnNNvToCbZQtWdaMbZTA_3RRGObu5PDoiBImgalVnnLU2yN4RMA'
+TELEMETA_GMAP_KEY = 'AIzaSyBcwFdXEpMduxGg0eOepva5VnkX_VF3Oxg'
 TELEMETA_CACHE_DIR = MEDIA_ROOT + 'cache/'
 TELEMETA_EXPORT_CACHE_DIR = MEDIA_ROOT + 'export/'
 TELEMETA_DATA_CACHE_DIR = TELEMETA_CACHE_DIR + "data/"
index 881b7a267f8302f01c5f40005ed0a67ece2ee351..8f9d8b8e790b5b3cd3e8eaca22ce668d98251bb9 100644 (file)
@@ -19,12 +19,13 @@ function ResourceMap(list, cfg) {
             });
             that.resize();
         });
-        google.load('maps', '2');
-        google.setOnLoadCallback(function() {
+        
+        
             that.createMap();
             that.parseResources();
-            $(window).bind('unload', google.maps.Unload);
-        });
+            // $(window).bind('unload', google.maps.Unload);
+        
+
     }
 
     that.resize = function() {
@@ -90,29 +91,42 @@ function ResourceMap(list, cfg) {
                 //var name      = $.trim(e.find('.resourcemap-name').text());
                 //var link      = e.find('a').attr('href');
                 //var linktitle = e.find('a').attr('title');
-                var marker    = new google.maps.Marker(new GLatLng(lat, lng), {title: name});
+                var marker    = new google.maps.Marker(new google.maps.LatLng(lat, lng), {title: name, map: that.map});
                 //var info      = that.makeInfoBox(name, link, linktitle);
-                google.maps.Event.addListener(marker, "click", function() {
+                google.maps.event.addListener(marker, "click", function() {
                     that.showResourceInfo(marker, e);
                     //marker.openInfoWindowHtml(info);
                 });
-                that.map.addOverlay(marker);
+                
             }
         });
     }        
 
     that.createMap = function() {
-        that.log("GMap loaded");
-        if (google.maps.BrowserIsCompatible()) {
-            that.map = new google.maps.Map2(that.container[0]);
-            var bounds = new GLatLngBounds();
-            that.map.setCenter(new GLatLng(0, 0), that.map.getBoundsZoomLevel(bounds)); // France
-            that.map.setUIToDefault();
-        } else {
-            that.log("Browser isn't compatible with GMap ?!");
-            that.toggle();
-        }
+          var mapOptions = {
+            zoom: 2,
+            center: new google.maps.LatLng(42.0, 6.0)
+            };
+        that.log("GMap loaded");    
+        that.map = new google.maps.Map(that.container[0], mapOptions);
+        // var bounds = new google.maps.LatLngBounds();
+        // that.map.setCenter(new google.maps.LatLng(0, 0), that.map.getBoundsZoomLevel(bounds)); // France
+        // that.map.setUIToDefault();
     }
 
     that.init(list, cfg);
 }
+
+
+function initialize() {
+    var resourceMap = new ResourceMap('.continents', {
+    'countryInfoUri': '/geo/country_info/RESOURCEID/'});
+}
+
+
+function loadScript() {
+  var script = document.createElement('script');
+  script.type = 'text/javascript';
+  script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&callback=initialize';
+  document.body.appendChild(script);
+}
index 9fec8aee423fdc4e39644ff2205d2591c7d01e9c..f9802cb92a0d1afe56d0f428adca53794959bb71 100644 (file)
@@ -6,12 +6,9 @@
 
 {% block extra_javascript %}
 {% if gmap_key %}
-<script src="http://www.google.com/jsapi?key={{ gmap_key }}" type="text/javascript"></script>
 <script src="{{ STATIC_URL }}telemeta/js/resourcemap.js" type="text/javascript"></script>
 <script type="text/javascript">
-var resourceMap = new ResourceMap('.continents', {
-    'countryInfoUri': '/geo/country_info/RESOURCEID/'
-});
+window.onload = loadScript;
 </script>
 {% endif %}
 {% endblock %}