forked from gkovacs/psetparty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oms.min.js
22 lines (22 loc) · 6.87 KB
/
oms.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(function(){/*
OverlappingMarkerSpiderfier
https://github.com/jawj/OverlappingMarkerSpiderfier
Copyright (c) 2011 - 2012 George MacKerron
Released under the MIT licence: http://opensource.org/licenses/mit-license
Note: The Google Maps API v3 must be included *before* this code
*/
var h=!0,i=null,n=!1,p,q={}.hasOwnProperty,s=[].slice;
if(((p=this.google)!=i?p.maps:void 0)!=i){var u=function(b,c){var a,e,d,f,g=this;this.map=b;c==i&&(c={});for(a in c)q.call(c,a)&&(e=c[a],this[a]=e);this.e=new this.constructor.g(this.map);this.n();this.b={};f=["click","zoom_changed","maptypeid_changed"];e=0;for(d=f.length;e<d;e++)a=f[e],t.addListener(this.map,a,function(){return g.unspiderfy()})},t,v,w,x,y,z,A;z=u.prototype;z.VERSION="0.3";v=google.maps;t=v.event;y=v.MapTypeId;A=2*Math.PI;z.keepSpiderfied=n;z.markersWontHide=n;z.markersWontMove=n;
z.nearbyDistance=20;z.circleSpiralSwitchover=9;z.circleFootSeparation=23;z.circleStartAngle=A/12;z.spiralFootSeparation=26;z.spiralLengthStart=11;z.spiralLengthFactor=4;z.spiderfiedZIndex=1E3;z.usualLegZIndex=10;z.highlightedLegZIndex=20;z.legWeight=1.5;z.legColors={usual:{},highlighted:{}};x=z.legColors.usual;w=z.legColors.highlighted;x[y.HYBRID]=x[y.SATELLITE]="#fff";w[y.HYBRID]=w[y.SATELLITE]="#f00";x[y.TERRAIN]=x[y.ROADMAP]="#444";w[y.TERRAIN]=w[y.ROADMAP]="#f00";z.n=function(){this.a=[];this.j=
[]};z.addMarker=function(b){var c,a=this;if(b._oms!=i)return this;b._oms=h;c=[t.addListener(b,"click",function(){return a.F(b)})];this.markersWontHide||c.push(t.addListener(b,"visible_changed",function(){return a.o(b,n)}));this.markersWontMove||c.push(t.addListener(b,"position_changed",function(){return a.o(b,h)}));this.j.push(c);this.a.push(b);return this};z.o=function(b,c){if(b._omsData!=i&&(c||!b.getVisible())&&!(this.s!=i||this.t!=i))return this.H(c?b:i)};z.getMarkers=function(){return this.a.slice(0)};
z.removeMarker=function(b){var c,a,e,d,f;b._omsData!=i&&this.unspiderfy();c=this.m(this.a,b);if(0>c)return this;e=this.j.splice(c,1)[0];d=0;for(f=e.length;d<f;d++)a=e[d],t.removeListener(a);delete b._oms;this.a.splice(c,1);return this};z.clearMarkers=function(){var b,c,a,e,d,f,g,j;this.unspiderfy();j=this.a;b=e=0;for(f=j.length;e<f;b=++e){a=j[b];c=this.j[b];d=0;for(g=c.length;d<g;d++)b=c[d],t.removeListener(b);delete a._oms}this.n();return this};z.addListener=function(b,c){var a,e;((e=(a=this.b)[b])!=
i?e:a[b]=[]).push(c);return this};z.removeListener=function(b,c){var a;a=this.m(this.b[b],c);0>a||this.b[b].splice(a,1);return this};z.clearListeners=function(b){this.b[b]=[];return this};z.trigger=function(){var b,c,a,e,d,f;c=arguments[0];b=2<=arguments.length?s.call(arguments,1):[];c=(a=this.b[c])!=i?a:[];f=[];e=0;for(d=c.length;e<d;e++)a=c[e],f.push(a.apply(i,b));return f};z.u=function(b,c){var a,e,d,f,g;d=this.circleFootSeparation*(2+b)/A;e=A/b;g=[];for(a=f=0;0<=b?f<b:f>b;a=0<=b?++f:--f)a=this.circleStartAngle+
a*e,g.push(new v.Point(c.x+d*Math.cos(a),c.y+d*Math.sin(a)));return g};z.v=function(b,c){var a,e,d,f,g;d=this.spiralLengthStart;a=0;g=[];for(e=f=0;0<=b?f<b:f>b;e=0<=b?++f:--f)a+=this.spiralFootSeparation/d+5E-4*e,e=new v.Point(c.x+d*Math.cos(a),c.y+d*Math.sin(a)),d+=A*this.spiralLengthFactor/a,g.push(e);return g};z.F=function(b){var c,a,e,d,f,g,j,k,m;d=b._omsData!=i;(!d||!this.keepSpiderfied)&&this.unspiderfy();if(d||this.map.getStreetView().getVisible())return this.trigger("click",b);d=[];f=[];c=
this.nearbyDistance;g=c*c;e=this.c(b.position);m=this.a;j=0;for(k=m.length;j<k;j++)c=m[j],c.map!=i&&c.getVisible()&&(a=this.c(c.position),this.f(a,e)<g?d.push({A:c,p:a}):f.push(c));return 1===d.length?this.trigger("click",b):this.G(d,f)};z.markersNearMarker=function(b,c){var a,e,d,f,g,j,k,m,l,r;c==i&&(c=n);if(this.e.getProjection()==i)throw"Must wait for 'idle' event on map before calling markersNearMarker";a=this.nearbyDistance;g=a*a;d=this.c(b.position);f=[];m=this.a;j=0;for(k=m.length;j<k;j++)if(a=
m[j],!(a===b||a.map==i||!a.getVisible()))if(e=this.c((l=(r=a._omsData)!=i?r.l:void 0)!=i?l:a.position),this.f(e,d)<g&&(f.push(a),c))break;return f};z.markersNearAnyOtherMarker=function(){var b,c,a,e,d,f,g,j,k,m,l,r;if(this.e.getProjection()==i)throw"Must wait for 'idle' event on map before calling markersNearAnyOtherMarker";f=this.nearbyDistance;b=f*f;e=this.a;f=[];l=0;for(a=e.length;l<a;l++)c=e[l],f.push({q:this.c((g=(k=c._omsData)!=i?k.l:void 0)!=i?g:c.position),d:n});l=this.a;c=g=0;for(k=l.length;g<
k;c=++g)if(a=l[c],a.map!=i&&a.getVisible()&&(e=f[c],!e.d)){r=this.a;a=j=0;for(m=r.length;j<m;a=++j)if(d=r[a],a!==c&&(d.map!=i&&d.getVisible())&&(d=f[a],(!(a<c)||d.d)&&this.f(e.q,d.q)<b)){e.d=d.d=h;break}}l=this.a;a=[];b=g=0;for(k=l.length;g<k;b=++g)c=l[b],f[b].d&&a.push(c);return a};z.z=function(b){var c=this;return{h:function(){return b._omsData.i.setOptions({strokeColor:c.legColors.highlighted[c.map.mapTypeId],zIndex:c.highlightedLegZIndex})},k:function(){return b._omsData.i.setOptions({strokeColor:c.legColors.usual[c.map.mapTypeId],
zIndex:c.usualLegZIndex})}}};z.G=function(b,c){var a,e,d,f,g,j;this.s=h;d=b.length;a=this.C(function(){var a,c,d;d=[];a=0;for(c=b.length;a<c;a++)j=b[a],d.push(j.p);return d}());d=d>=this.circleSpiralSwitchover?this.v(d,a).reverse():this.u(d,a);var k,m,l,r=this;l=[];k=0;for(m=d.length;k<m;k++)e=d[k],a=this.D(e),g=this.B(b,function(a){return r.f(a.p,e)}),g=g.A,f=new v.Polyline({map:this.map,path:[g.position,a],strokeColor:this.legColors.usual[this.map.mapTypeId],strokeWeight:this.legWeight,zIndex:this.usualLegZIndex}),
g._omsData={l:g.position,i:f},this.legColors.highlighted[this.map.mapTypeId]!==this.legColors.usual[this.map.mapTypeId]&&(f=this.z(g),g._omsData.w={h:t.addListener(g,"mouseover",f.h),k:t.addListener(g,"mouseout",f.k)}),g.setPosition(a),g.setZIndex(Math.round(this.spiderfiedZIndex+e.y)),l.push(g);delete this.s;this.r=h;return this.trigger("spiderfy",l,c)};z.unspiderfy=function(b){var c,a,e,d,f,g,j;b==i&&(b=i);if(this.r==i)return this;this.t=h;d=[];e=[];j=this.a;f=0;for(g=j.length;f<g;f++)a=j[f],a._omsData!=
i?(a._omsData.i.setMap(i),a!==b&&a.setPosition(a._omsData.l),a.setZIndex(i),c=a._omsData.w,c!=i&&(t.removeListener(c.h),t.removeListener(c.k)),delete a._omsData,d.push(a)):e.push(a);delete this.t;delete this.r;this.trigger("unspiderfy",d,e);return this};z.f=function(b,c){var a,e;a=b.x-c.x;e=b.y-c.y;return a*a+e*e};z.C=function(b){var c,a,e,d,f;d=a=e=0;for(f=b.length;d<f;d++)c=b[d],a+=c.x,e+=c.y;b=b.length;return new v.Point(a/b,e/b)};z.c=function(b){return this.e.getProjection().fromLatLngToDivPixel(b)};
z.D=function(b){return this.e.getProjection().fromDivPixelToLatLng(b)};z.B=function(b,c){var a,e,d,f,g,j;d=g=0;for(j=b.length;g<j;d=++g)if(f=b[d],f=c(f),!("undefined"!==typeof a&&a!==i)||f<e)e=f,a=d;return b.splice(a,1)[0]};z.m=function(b,c){var a,e,d,f;if(b.indexOf!=i)return b.indexOf(c);a=d=0;for(f=b.length;d<f;a=++d)if(e=b[a],e===c)return a;return-1};u.g=function(b){return this.setMap(b)};u.g.prototype=new v.OverlayView;u.g.prototype.draw=function(){};this.OverlappingMarkerSpiderfier=u};}).call(this);
/* Mon 7 Jan 2013 18:10:52 GMT */