diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2016-08-25 11:57:57 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2016-08-25 15:25:27 +0200 |
| commit | 251344903d1ddee1672c4030b87349cd29fdc934 (patch) | |
| tree | c761e33b1a2be9449ce18229b29aa06e17c25580 /addons/website_google_map/static/src | |
| parent | f883022cc8faecb8a8ba497d7834e675a98126c8 (diff) | |
[IMP] website_google_map: update markerclusterer
An update of the library is necessary, since imarker images ("m*.png")
are not accessible on googlecode anymore. They should now be added
directly with the library.
Diffstat (limited to 'addons/website_google_map/static/src')
18 files changed, 43 insertions, 40 deletions
diff --git a/addons/website_google_map/static/src/js/website_google_map.js b/addons/website_google_map/static/src/js/website_google_map.js index 53e5342bbfc..0e8299d2c98 100644 --- a/addons/website_google_map/static/src/js/website_google_map.js +++ b/addons/website_google_map/static/src/js/website_google_map.js @@ -16,6 +16,9 @@ function initialize_map() { var partners = new google.maps.MarkerImage('/website_google_map/static/src/img/partners.png', new google.maps.Size(25, 25)); var partner_url = document.body.getAttribute('data-partner-url') || ''; var markers = []; + var options = { + imagePath: '/website_google_map/static/src/lib/images/m' + }; google.maps.event.addListener(map, 'click', function() { infoWindow.close(); @@ -75,7 +78,7 @@ function initialize_map() { for (var i = 0; i < odoo_partner_data.counter; i++) { set_marker(odoo_partner_data.partners[i]); } - var markerCluster = new MarkerClusterer(map, markers); + var markerCluster = new MarkerClusterer(map, markers, options); } } diff --git a/addons/website_google_map/static/src/lib/images/conv30.png b/addons/website_google_map/static/src/lib/images/conv30.png Binary files differnew file mode 100644 index 00000000000..a50f61f0b9e --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/conv30.png diff --git a/addons/website_google_map/static/src/lib/images/conv40.png b/addons/website_google_map/static/src/lib/images/conv40.png Binary files differnew file mode 100644 index 00000000000..2fe31a5758c --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/conv40.png diff --git a/addons/website_google_map/static/src/lib/images/conv50.png b/addons/website_google_map/static/src/lib/images/conv50.png Binary files differnew file mode 100644 index 00000000000..cbab98b318d --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/conv50.png diff --git a/addons/website_google_map/static/src/lib/images/heart30.png b/addons/website_google_map/static/src/lib/images/heart30.png Binary files differnew file mode 100644 index 00000000000..c6067a7e6c5 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/heart30.png diff --git a/addons/website_google_map/static/src/lib/images/heart40.png b/addons/website_google_map/static/src/lib/images/heart40.png Binary files differnew file mode 100644 index 00000000000..e79ba0a1b12 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/heart40.png diff --git a/addons/website_google_map/static/src/lib/images/heart50.png b/addons/website_google_map/static/src/lib/images/heart50.png Binary files differnew file mode 100644 index 00000000000..26c2252477f --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/heart50.png diff --git a/addons/website_google_map/static/src/lib/images/m1.png b/addons/website_google_map/static/src/lib/images/m1.png Binary files differnew file mode 100644 index 00000000000..329ff524c59 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/m1.png diff --git a/addons/website_google_map/static/src/lib/images/m2.png b/addons/website_google_map/static/src/lib/images/m2.png Binary files differnew file mode 100644 index 00000000000..b999cbcf694 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/m2.png diff --git a/addons/website_google_map/static/src/lib/images/m3.png b/addons/website_google_map/static/src/lib/images/m3.png Binary files differnew file mode 100644 index 00000000000..9f30b3092b2 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/m3.png diff --git a/addons/website_google_map/static/src/lib/images/m4.png b/addons/website_google_map/static/src/lib/images/m4.png Binary files differnew file mode 100644 index 00000000000..0d3f8263bd0 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/m4.png diff --git a/addons/website_google_map/static/src/lib/images/m5.png b/addons/website_google_map/static/src/lib/images/m5.png Binary files differnew file mode 100644 index 00000000000..61387d2ab5c --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/m5.png diff --git a/addons/website_google_map/static/src/lib/images/people35.png b/addons/website_google_map/static/src/lib/images/people35.png Binary files differnew file mode 100644 index 00000000000..6a5a209decc --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/people35.png diff --git a/addons/website_google_map/static/src/lib/images/people45.png b/addons/website_google_map/static/src/lib/images/people45.png Binary files differnew file mode 100644 index 00000000000..219c62e41d1 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/people45.png diff --git a/addons/website_google_map/static/src/lib/images/people55.png b/addons/website_google_map/static/src/lib/images/people55.png Binary files differnew file mode 100644 index 00000000000..6e88d1ef05e --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/people55.png diff --git a/addons/website_google_map/static/src/lib/images/pin.png b/addons/website_google_map/static/src/lib/images/pin.png Binary files differnew file mode 100644 index 00000000000..3f830a31661 --- /dev/null +++ b/addons/website_google_map/static/src/lib/images/pin.png diff --git a/addons/website_google_map/static/src/lib/markerclusterer.js b/addons/website_google_map/static/src/lib/markerclusterer.js index 1afbe5aad94..554fcecec43 100644..100755 --- a/addons/website_google_map/static/src/lib/markerclusterer.js +++ b/addons/website_google_map/static/src/lib/markerclusterer.js @@ -1,6 +1,6 @@ // ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS -// @externs_url http://closure-compiler.googlecode.com/svn/trunk/contrib/externs/maps/google_maps_api_v3_3.js +// @externs_url https://raw.githubusercontent.com/google/closure-compiler/master/contrib/externs/maps/google_maps_api_v3.js // ==/ClosureCompiler== /** @@ -17,6 +17,9 @@ */ /** + * @license + * Copyright 2010 Google Inc. All Rights Reserved. + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -43,7 +46,7 @@ * cluster. * 'zoomOnClick': (boolean) Whether the default behaviour of clicking on a * cluster is to zoom into it. - * 'averageCenter': (boolean) Wether the center of each cluster should be + * 'averageCenter': (boolean) Whether the center of each cluster should be * the average of all markers in the cluster. * 'minimumClusterSize': (number) The minimum number of markers to be in a * cluster before the markers are hidden and a count @@ -56,6 +59,7 @@ * 'textColor': (string) The text color. * 'textSize': (number) The text size. * 'backgroundPosition': (string) The position of the backgound x, y. + * 'iconAnchor': (Array) The anchor position of the icon x, y. * @constructor * @extends google.maps.OverlayView */ @@ -161,14 +165,10 @@ function MarkerClusterer(map, opt_markers, opt_options) { // Add the map event listeners var that = this; google.maps.event.addListener(this.map_, 'zoom_changed', function() { - var maxZoom = that.map_.mapTypes[that.map_.getMapTypeId()].maxZoom; var zoom = that.map_.getZoom(); - if (zoom < 0 || zoom > maxZoom) { - return; - } if (that.prevZoom_ != zoom) { - that.prevZoom_ = that.map_.getZoom(); + that.prevZoom_ = zoom; that.resetViewport(); } }); @@ -190,9 +190,7 @@ function MarkerClusterer(map, opt_markers, opt_options) { * @type {string} * @private */ -MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_ = - 'http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/' + - 'images/m'; +MarkerClusterer.prototype.MARKER_CLUSTER_IMAGE_PATH_ = '../images/m'; /** @@ -344,7 +342,7 @@ MarkerClusterer.prototype.setMaxZoom = function(maxZoom) { * @return {number} The max zoom level. */ MarkerClusterer.prototype.getMaxZoom = function() { - return this.maxZoom_ || this.map_.mapTypes[this.map_.getMapTypeId()].maxZoom; + return this.maxZoom_; }; @@ -988,7 +986,7 @@ Cluster.prototype.updateIcon = function() { var zoom = this.map_.getZoom(); var mz = this.markerClusterer_.getMaxZoom(); - if (zoom > mz) { + if (mz && zoom > mz) { // The zoom is greater than our max zoom so show all the markers in cluster. for (var i = 0, marker; marker = this.markers_[i]; i++) { marker.setMap(this.map_); @@ -1045,12 +1043,14 @@ function ClusterIcon(cluster, styles, opt_padding) { /** * Triggers the clusterclick event and zoom's if the option is set. + * + * @param {google.maps.MouseEvent} event The event to propagate */ -ClusterIcon.prototype.triggerClusterClick = function() { +ClusterIcon.prototype.triggerClusterClick = function(event) { var markerClusterer = this.cluster_.getMarkerClusterer(); // Trigger the clusterclick event. - google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_); + google.maps.event.trigger(markerClusterer, 'clusterclick', this.cluster_, event); if (markerClusterer.isZoomOnClick()) { // Zoom into the cluster. @@ -1075,8 +1075,18 @@ ClusterIcon.prototype.onAdd = function() { panes.overlayMouseTarget.appendChild(this.div_); var that = this; - google.maps.event.addDomListener(this.div_, 'click', function() { - that.triggerClusterClick(); + var isDragging = false; + google.maps.event.addDomListener(this.div_, 'click', function(event) { + // Only perform click when not preceded by a drag + if (!isDragging) { + that.triggerClusterClick(event); + } + }); + google.maps.event.addDomListener(this.div_, 'mousedown', function() { + isDragging = false; + }); + google.maps.event.addDomListener(this.div_, 'mousemove', function() { + isDragging = true; }); }; @@ -1090,8 +1100,14 @@ ClusterIcon.prototype.onAdd = function() { */ ClusterIcon.prototype.getPosFromLatLng_ = function(latlng) { var pos = this.getProjection().fromLatLngToDivPixel(latlng); - pos.x -= parseInt(this.width_ / 2, 10); - pos.y -= parseInt(this.height_ / 2, 10); + + if (typeof this.iconAnchor_ === 'object' && this.iconAnchor_.length === 2) { + pos.x -= this.iconAnchor_[0]; + pos.y -= this.iconAnchor_[1]; + } else { + pos.x -= parseInt(this.width_ / 2, 10); + pos.y -= parseInt(this.height_ / 2, 10); + } return pos; }; @@ -1187,6 +1203,7 @@ ClusterIcon.prototype.useStyle = function() { this.anchor_ = style['anchor']; this.textSize_ = style['textSize']; this.backgroundPosition_ = style['backgroundPosition']; + this.iconAnchor_ = style['iconAnchor']; }; @@ -1217,6 +1234,10 @@ ClusterIcon.prototype.createCss = function(pos) { this.anchor_[0] < this.height_) { style.push('height:' + (this.height_ - this.anchor_[0]) + 'px; padding-top:' + this.anchor_[0] + 'px;'); + } else if (typeof this.anchor_[0] === 'number' && this.anchor_[0] < 0 && + -this.anchor_[0] < this.height_) { + style.push('height:' + this.height_ + 'px; line-height:' + (this.height_ + this.anchor_[0]) + + 'px;'); } else { style.push('height:' + this.height_ + 'px; line-height:' + this.height_ + 'px;'); diff --git a/addons/website_google_map/static/src/lib/markerclusterer_compiled.js b/addons/website_google_map/static/src/lib/markerclusterer_compiled.js deleted file mode 100644 index 1e1241fa627..00000000000 --- a/addons/website_google_map/static/src/lib/markerclusterer_compiled.js +++ /dev/null @@ -1,21 +0,0 @@ -(function(){var d=null;function e(a){return function(b){this[a]=b}}function i(a){return function(){return this[a]}}var j; -function k(a,b,c){this.extend(k,google.maps.OverlayView);this.b=a;this.a=[];this.f=[];this.ca=[53,56,66,78,90];this.j=[];this.A=!1;c=c||{};this.g=c.gridSize||60;this.l=c.minimumClusterSize||2;this.J=c.maxZoom||d;this.j=c.styles||[];this.X=c.imagePath||this.Q;this.W=c.imageExtension||this.P;this.O=!0;if(c.zoomOnClick!=void 0)this.O=c.zoomOnClick;this.r=!1;if(c.averageCenter!=void 0)this.r=c.averageCenter;l(this);this.setMap(a);this.K=this.b.getZoom();var f=this;google.maps.event.addListener(this.b, -"zoom_changed",function(){var a=f.b.mapTypes[f.b.getMapTypeId()].maxZoom,b=f.b.getZoom();if(!(b<0||b>a)&&f.K!=b)f.K=f.b.getZoom(),f.m()});google.maps.event.addListener(this.b,"idle",function(){f.i()});b&&b.length&&this.C(b,!1)}j=k.prototype;j.Q="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m";j.P="png";j.extend=function(a,b){return function(a){for(var b in a.prototype)this.prototype[b]=a.prototype[b];return this}.apply(a,[b])}; -j.onAdd=function(){if(!this.A)this.A=!0,n(this)};j.draw=function(){};function l(a){if(!a.j.length)for(var b=0,c;c=a.ca[b];b++)a.j.push({url:a.X+(b+1)+"."+a.W,height:c,width:c})}j.S=function(){for(var a=this.o(),b=new google.maps.LatLngBounds,c=0,f;f=a[c];c++)b.extend(f.getPosition());this.b.fitBounds(b)};j.z=i("j");j.o=i("a");j.V=function(){return this.a.length};j.ba=e("J");j.I=function(){return this.J||this.b.mapTypes[this.b.getMapTypeId()].maxZoom}; -j.G=function(a,b){for(var c=0,f=a.length,g=f;g!==0;)g=parseInt(g/10,10),c++;c=Math.min(c,b);return{text:f,index:c}};j.$=e("G");j.H=i("G");j.C=function(a,b){for(var c=0,f;f=a[c];c++)q(this,f);b||this.i()};function q(a,b){b.s=!1;b.draggable&&google.maps.event.addListener(b,"dragend",function(){b.s=!1;a.L()});a.a.push(b)}j.q=function(a,b){q(this,a);b||this.i()}; -function s(a,b){var c=-1;if(a.a.indexOf)c=a.a.indexOf(b);else for(var f=0,g;g=a.a[f];f++)if(g==b){c=f;break}if(c==-1)return!1;a.a.splice(c,1);return!0}j.Y=function(a,b){var c=s(this,a);return!b&&c?(this.m(),this.i(),!0):!1};j.Z=function(a,b){for(var c=!1,f=0,g;g=a[f];f++)g=s(this,g),c=c||g;if(!b&&c)return this.m(),this.i(),!0};j.U=function(){return this.f.length};j.getMap=i("b");j.setMap=e("b");j.w=i("g");j.aa=e("g"); -j.v=function(a){var b=this.getProjection(),c=new google.maps.LatLng(a.getNorthEast().lat(),a.getNorthEast().lng()),f=new google.maps.LatLng(a.getSouthWest().lat(),a.getSouthWest().lng());c=b.fromLatLngToDivPixel(c);c.x+=this.g;c.y-=this.g;f=b.fromLatLngToDivPixel(f);f.x-=this.g;f.y+=this.g;c=b.fromDivPixelToLatLng(c);b=b.fromDivPixelToLatLng(f);a.extend(c);a.extend(b);return a};j.R=function(){this.m(!0);this.a=[]}; -j.m=function(a){for(var b=0,c;c=this.f[b];b++)c.remove();for(b=0;c=this.a[b];b++)c.s=!1,a&&c.setMap(d);this.f=[]};j.L=function(){var a=this.f.slice();this.f.length=0;this.m();this.i();window.setTimeout(function(){for(var b=0,c;c=a[b];b++)c.remove()},0)};j.i=function(){n(this)}; -function n(a){if(a.A)for(var b=a.v(new google.maps.LatLngBounds(a.b.getBounds().getSouthWest(),a.b.getBounds().getNorthEast())),c=0,f;f=a.a[c];c++)if(!f.s&&b.contains(f.getPosition())){for(var g=a,r=4E4,o=d,v=0,m=void 0;m=g.f[v];v++){var h=m.getCenter();if(h){var p=f.getPosition();if(!h||!p)h=0;else{var w=(p.lat()-h.lat())*Math.PI/180,x=(p.lng()-h.lng())*Math.PI/180;h=Math.sin(w/2)*Math.sin(w/2)+Math.cos(h.lat()*Math.PI/180)*Math.cos(p.lat()*Math.PI/180)*Math.sin(x/2)*Math.sin(x/2);h=6371*2*Math.atan2(Math.sqrt(h), -Math.sqrt(1-h))}h<r&&(r=h,o=m)}}o&&o.F.contains(f.getPosition())?o.q(f):(m=new t(g),m.q(f),g.f.push(m))}}function t(a){this.k=a;this.b=a.getMap();this.g=a.w();this.l=a.l;this.r=a.r;this.d=d;this.a=[];this.F=d;this.n=new u(this,a.z(),a.w())}j=t.prototype; -j.q=function(a){var b;a:if(this.a.indexOf)b=this.a.indexOf(a)!=-1;else{b=0;for(var c;c=this.a[b];b++)if(c==a){b=!0;break a}b=!1}if(b)return!1;if(this.d){if(this.r)c=this.a.length+1,b=(this.d.lat()*(c-1)+a.getPosition().lat())/c,c=(this.d.lng()*(c-1)+a.getPosition().lng())/c,this.d=new google.maps.LatLng(b,c),y(this)}else this.d=a.getPosition(),y(this);a.s=!0;this.a.push(a);b=this.a.length;b<this.l&&a.getMap()!=this.b&&a.setMap(this.b);if(b==this.l)for(c=0;c<b;c++)this.a[c].setMap(d);b>=this.l&&a.setMap(d); -if(this.b.getZoom()>this.k.I())for(a=0;b=this.a[a];a++)b.setMap(this.b);else if(this.a.length<this.l)z(this.n);else{b=this.k.H()(this.a,this.k.z().length);this.n.setCenter(this.d);a=this.n;a.B=b;a.ga=b.text;a.ea=b.index;if(a.c)a.c.innerHTML=b.text;b=Math.max(0,a.B.index-1);b=Math.min(a.j.length-1,b);b=a.j[b];a.da=b.url;a.h=b.height;a.p=b.width;a.M=b.textColor;a.e=b.anchor;a.N=b.textSize;a.D=b.backgroundPosition;this.n.show()}return!0}; -j.getBounds=function(){for(var a=new google.maps.LatLngBounds(this.d,this.d),b=this.o(),c=0,f;f=b[c];c++)a.extend(f.getPosition());return a};j.remove=function(){this.n.remove();this.a.length=0;delete this.a};j.T=function(){return this.a.length};j.o=i("a");j.getCenter=i("d");function y(a){a.F=a.k.v(new google.maps.LatLngBounds(a.d,a.d))}j.getMap=i("b"); -function u(a,b,c){a.k.extend(u,google.maps.OverlayView);this.j=b;this.fa=c||0;this.u=a;this.d=d;this.b=a.getMap();this.B=this.c=d;this.t=!1;this.setMap(this.b)}j=u.prototype; -j.onAdd=function(){this.c=document.createElement("DIV");if(this.t)this.c.style.cssText=A(this,B(this,this.d)),this.c.innerHTML=this.B.text;this.getPanes().overlayMouseTarget.appendChild(this.c);var a=this;google.maps.event.addDomListener(this.c,"click",function(){var b=a.u.k;google.maps.event.trigger(b,"clusterclick",a.u);b.O&&a.b.fitBounds(a.u.getBounds())})};function B(a,b){var c=a.getProjection().fromLatLngToDivPixel(b);c.x-=parseInt(a.p/2,10);c.y-=parseInt(a.h/2,10);return c} -j.draw=function(){if(this.t){var a=B(this,this.d);this.c.style.top=a.y+"px";this.c.style.left=a.x+"px"}};function z(a){if(a.c)a.c.style.display="none";a.t=!1}j.show=function(){if(this.c)this.c.style.cssText=A(this,B(this,this.d)),this.c.style.display="";this.t=!0};j.remove=function(){this.setMap(d)};j.onRemove=function(){if(this.c&&this.c.parentNode)z(this),this.c.parentNode.removeChild(this.c),this.c=d};j.setCenter=e("d"); -function A(a,b){var c=[];c.push("background-image:url("+a.da+");");c.push("background-position:"+(a.D?a.D:"0 0")+";");typeof a.e==="object"?(typeof a.e[0]==="number"&&a.e[0]>0&&a.e[0]<a.h?c.push("height:"+(a.h-a.e[0])+"px; padding-top:"+a.e[0]+"px;"):c.push("height:"+a.h+"px; line-height:"+a.h+"px;"),typeof a.e[1]==="number"&&a.e[1]>0&&a.e[1]<a.p?c.push("width:"+(a.p-a.e[1])+"px; padding-left:"+a.e[1]+"px;"):c.push("width:"+a.p+"px; text-align:center;")):c.push("height:"+a.h+"px; line-height:"+a.h+ -"px; width:"+a.p+"px; text-align:center;");c.push("cursor:pointer; top:"+b.y+"px; left:"+b.x+"px; color:"+(a.M?a.M:"black")+"; position:absolute; font-size:"+(a.N?a.N:11)+"px; font-family:Arial,sans-serif; font-weight:bold");return c.join("")}window.MarkerClusterer=k;k.prototype.addMarker=k.prototype.q;k.prototype.addMarkers=k.prototype.C;k.prototype.clearMarkers=k.prototype.R;k.prototype.fitMapToMarkers=k.prototype.S;k.prototype.getCalculator=k.prototype.H;k.prototype.getGridSize=k.prototype.w; -k.prototype.getExtendedBounds=k.prototype.v;k.prototype.getMap=k.prototype.getMap;k.prototype.getMarkers=k.prototype.o;k.prototype.getMaxZoom=k.prototype.I;k.prototype.getStyles=k.prototype.z;k.prototype.getTotalClusters=k.prototype.U;k.prototype.getTotalMarkers=k.prototype.V;k.prototype.redraw=k.prototype.i;k.prototype.removeMarker=k.prototype.Y;k.prototype.removeMarkers=k.prototype.Z;k.prototype.resetViewport=k.prototype.m;k.prototype.repaint=k.prototype.L;k.prototype.setCalculator=k.prototype.$; -k.prototype.setGridSize=k.prototype.aa;k.prototype.setMaxZoom=k.prototype.ba;k.prototype.onAdd=k.prototype.onAdd;k.prototype.draw=k.prototype.draw;t.prototype.getCenter=t.prototype.getCenter;t.prototype.getSize=t.prototype.T;t.prototype.getMarkers=t.prototype.o;u.prototype.onAdd=u.prototype.onAdd;u.prototype.draw=u.prototype.draw;u.prototype.onRemove=u.prototype.onRemove; -})(); |
