'+
+ (partner_url.length ? '
'+p.name +'' : '
'+p.name+'' )+
+ (p.type ? '
' + p.type + '' : '')+
+ '
' + p.address + '
'+
+ '
'
+ );
+ infoWindow.open(map, marker);
+ };
+
+ // Create a bubble for a partner
+ var set_marker = function(partner) {
+ // If no lat & long, geocode address
+ // TODO: a server cronjob that will store these coordinates in database instead of resolving them on-the-fly
+ if (!partner.latitude && !partner.longitude) {
+ Geocoder.geocode({'address': partner.address}, function(results, status) {
+ if (status === google.maps.GeocoderStatus.OK) {
+ var location = results[0].geometry.location;
+ partner.latitude = location.ob;
+ partner.longitude = location.pb;
+ var marker = new google.maps.Marker({
+ partner: partner,
+ map: map,
+ icon: partners,
+ position: location
+ });
+ google.maps.event.addListener(marker, 'click', onMarkerClick);
+ markers.push(marker);
+ } else {
+ console.debug('Geocode was not successful for the following reason: ' + status);
+ }
+ });
+ } else {
+ var latLng = new google.maps.LatLng(partner.latitude, partner.longitude);
+ var marker = new google.maps.Marker({
+ partner: partner,
+ icon: partners,
+ map: map,
+ position: latLng
+ });
+ google.maps.event.addListener(marker, 'click', onMarkerClick);
+ markers.push(marker);
+ }
+ };
+
+ /* eslint-disable no-undef */
+ // Create the markers and cluster them on the map
+ if (odoo_partner_data){ /* odoo_partner_data special variable should have been defined in google_map.xml */
+ for (var i = 0; i < odoo_partner_data.counter; i++) {
+ set_marker(odoo_partner_data.partners[i]);
+ }
+ new MarkerClusterer(map, markers, options);
+ }
+ /* eslint-enable no-undef */
+}
+
+// Initialize map once the DOM has been loaded
+google.maps.event.addDomListener(window, 'load', initialize_map);
diff --git a/views/google_map.xml b/views/google_map.xml
new file mode 100644
index 0000000..ed174fb
--- /dev/null
+++ b/views/google_map.xml
@@ -0,0 +1,29 @@
+
+