Remove Address::updateGeocoding unused parameter
[platal.git] / htdocs / javascript / maps.js
index db3020d..f0a7d3f 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *  Copyright (C) 2003-2011 Polytechnique.org                              *
+ *  Copyright (C) 2003-2014 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
 
 function map_initialize()
 {
-    var latlng = new google.maps.LatLng(0, 0);
     var myOptions = {
         zoom: 1,
-        center: latlng,
+        center: new google.maps.LatLng(0, 0),
         mapTypeId: google.maps.MapTypeId.ROADMAP
     };
     var map = new google.maps.Map($('#map_canvas').get(0), myOptions);
 
-    $.xget('map/ajax', function(json_data) {
+    $.xget(window.location.href, {ajax: true}, function(json_data) {
         var data = jQuery.parseJSON(json_data);
         var dots = data.data;
         var count = dots.length;
+        var info_window = new google.maps.InfoWindow({});
+        var parameters = ", '_blank', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=840,height=600'";
         var markers = [];
 
         for (var i = 0; i < count; ++i) {
@@ -47,23 +48,28 @@ function map_initialize()
                 var link_array = new Array();
 
                 for (var j = 0; j < hrpids.length; ++j) {
-                    link_array[j] = '<a href="profile/' + hrpids[j] + '">' + names[j] + '</a>';
+                    link_array[j] = '<a href="profile/' + hrpids[j] + '" onclick="window.open(this.href' + parameters + '); return false;">' + names[j] + '</a>';
                 }
                 var link = link_array.join('<br />');
             } else {
-                var link = '<a href="profile/' + dots[i].hrpid + '">' + dots[i].name + '</a>';
+                var link = '<a href="profile/' + dots[i].hrpid + '" onclick="window.open(this.href' + parameters + '); return false;">' + dots[i].name + '</a>';
             }
 
-            var marker = new MarkerWithLabel({
+            var marker = new google.maps.Marker({
                 'position': latLng,
-                'labelContent': link,
-                'labelClass': 'marker_label'
+                'map': map,
+                'title': dots[i].name
             });
             marker.bindTo('icon', new ColoredIcon(color));
             marker.set('color', color);
+            marker.set('html', link);
+            google.maps.event.addListener(marker, 'click', function() {
+                info_window.setContent(this.html);
+                info_window.open(map, this);
+            });
             markers.push(marker);
         }
-        var mc = new MarkerClusterer(map, markers);
+        var mc = new MarkerClusterer(map, markers, {'averageCenter': true});
     });
 }
 
@@ -71,7 +77,7 @@ function ColoredIcon(color)
 {
     this.set('starcolor', null);
     this.set('color', color);
-    this.set('icon', 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=|' + color);
+    this.set('icon', 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=|' + color);
 }
 
 ColoredIcon.prototype = new google.maps.MVCObject();
@@ -166,4 +172,4 @@ function color_average(color_array)
     return color_code;
 }
 
-// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: