New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

overlapping-marker-spiderfier

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

overlapping-marker-spiderfier - npm Package Compare versions

Comparing version

to
1.1.3

2

dist/oms.min.js

@@ -7,2 +7,2 @@ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OverlappingMarkerSpiderfier=t():e.OverlappingMarkerSpiderfier=t()}(this,function(){return function(e){function t(r){if(i[r])return i[r].exports;var n=i[r]={exports:{},id:r,loaded:!1};return e[r].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var i={};return t.m=e,t.c=i,t.p="/dist/",t(0)}([function(e,t,i){e.exports=i(1)},function(e,t){/** @preserve OverlappingMarkerSpiderfier

*/
var i={}.hasOwnProperty,r=[].slice;this.OverlappingMarkerSpiderfier=function(){function e(e,r){var n,s,o,a,l,u;this.map=e,null==r&&(r={});for(o in r)i.call(r,o)&&(u=r[o],this[o]=u);for(this.projHelper=new this.constructor.ProjHelper(this.map),this.initMarkerArrays(),this.listeners={},l=["click","zoom_changed","maptypeid_changed"],s=0,a=l.length;a>s;s++)n=l[s],t.addListener(this.map,n,function(e){return function(){return e.unspiderfy()}}(this));this.nudgeStackedMarkers&&t.addListenerOnce(this.map,"idle",function(e){return function(){return t.addListener(e.map,"zoom_changed",function(){return e.mapZoomChangeListener()}),e.mapZoomChangeListener()}}(this))}var t,n,s,o,a,l,u;return l=e.prototype,n=google.maps,t=n.event,a=n.MapTypeId,u=2*Math.PI,l.keepSpiderfied=!1,l.markersWontHide=!1,l.markersWontMove=!1,l.spiderfiedShadowColor="white",l.nudgeStackedMarkers=!0,l.minNudgeZoomLevel=8,l.nudgeRadius=1,l.markerCountInBaseNudgeLevel=9,l.maxNudgeCount=9,l.nudgeBucketSize=12,l.nearbyDistance=20,l.circleSpiralSwitchover=9,l.circleFootSeparation=23,l.circleStartAngle=u/12,l.spiralFootSeparation=26,l.spiralLengthStart=11,l.spiralLengthFactor=4,l.spiderfiedZIndex=1e3,l.usualLegZIndex=10,l.highlightedLegZIndex=20,l.event="click",l.minZoomLevel=!1,l.lineToCenter=!0,l.legWeight=1.5,l.legColors={usual:{},highlighted:{}},o=l.legColors.usual,s=l.legColors.highlighted,o[a.HYBRID]=o[a.SATELLITE]="#fff",s[a.HYBRID]=s[a.SATELLITE]="#f00",o[a.TERRAIN]=o[a.ROADMAP]="#444",s[a.TERRAIN]=s[a.ROADMAP]="#f00",l.initMarkerArrays=function(){return this.markers=[],this.markerListenerRefs=[]},l.addMarker=function(e){var i;return null!=e._oms?this:(e._oms=!0,i=[t.addListener(e,this.event,function(t){return function(i){return t.spiderListener(e,i)}}(this))],this.markersWontHide||i.push(t.addListener(e,"visible_changed",function(t){return function(){return t.markerChangeListener(e,!1)}}(this))),this.markersWontMove||i.push(t.addListener(e,"position_changed",function(t){return function(){return t.markerChangeListener(e,!0)}}(this))),this.markerListenerRefs.push(i),this.markers.push(e),this.isNudgingActive()&&this.requestNudge(),this)},l.nudgeTimeout=null,l.requestNudge=function(){return this.nudgeTimeout&&clearTimeout(this.nudgeTimeout),this.nudgeTimeout=setTimeout(function(e){return function(){return e.nudgeAllMarkers()}}(this),10)},l.isNudgingActive=function(){return this.nudgeStackedMarkers&&!(this.minNudgeZoomLevel&&this.map.getZoom()<this.minNudgeZoomLevel)},l.markerChangeListener=function(e,t){return null==e._omsData||e._omsData.nudged||!t&&e.getVisible()||null!=this.spiderfying||null!=this.unspiderfying?void 0:this.unspiderfy(t?e:null)},l.countsPerLevel=[1,1],l.levelsByCount=[],l.getCountPerNudgeLevel=function(e){return null!=this.countsPerLevel[e]?this.countsPerLevel[e]:this.countsPerLevel[e]=this.getCountPerNudgeLevel(e-1)+Math.pow(2,e-2)*this.markerCountInBaseNudgeLevel},l.getNudgeLevel=function(e){var t;if(null!=this.levelsByCount[e])return this.levelsByCount[e];for(t=0;e>=this.countsPerLevel[t];)t+1>=this.countsPerLevel.length&&this.getCountPerNudgeLevel(t+1),t++;return this.levelsByCount[e]=t-1},l.nudgeAllMarkers=function(){var e,t,i,r,n,s,o,a,l,h,d,g,p,f,m,c,v,k,L,y,P,D;if(this.isNudgingActive()){for(m={},r=[],n=[],e=1/((1+this.nudgeBucketSize)*this.nudgeRadius),o=function(t){return function(t){return Math.floor(t.x*e)+","+Math.floor(t.y*e)}}(this),c=this.markers,P=[],a=0,l=c.length;l>a;a++){for(h=c[a],d=!1,p=this.llToPt(null!=(v=null!=(k=h._omsData)?k.usualPosition:void 0)?v:h.position),g={x:p.x,y:p.y},f=o(p);null!=m[f]&&(null==this.maxNudgeCount||this.maxNudgeCount>=m[f]);)s=m[f],m[f]+=1,null!=r[s]?(t=r[s],i=n[s]):(D=this.getNudgeLevel(s),r[s]=t=20*Math.sin(u*s/this.markerCountInBaseNudgeLevel/D)*this.nudgeRadius*D,n[s]=i=20*Math.cos(u*s/this.markerCountInBaseNudgeLevel/D)*this.nudgeRadius*D),p.x=g.x+t,p.y=g.y+i,this.nudged=!0,d=!0,f=o(p);d?(h._omsData={usualPosition:null!=(L=null!=(y=h._omsData)?y.usualPosition:void 0)?L:h.position,nudged:!0},h.setPosition(this.ptToLl(p))):null!=h._omsData&&h._omsData.nudged&&(h.setPosition(h._omsData.usualPosition),delete h._omsData),P.push(f in m?void 0:m[f]=1)}return P}},l.resetNudgedMarkers=function(){var e,t,i,r;if(this.nudged){for(r=this.markers,e=0,t=r.length;t>e;e++)i=r[e],null!=i._omsData&&i._omsData.nudged&&(i.setPosition(i._omsData.usualPosition),delete i._omsData);return delete this.nudged}},l.mapZoomChangeListener=function(){return this.minNudgeZoomLevel&&this.map.getZoom()<this.minNudgeZoomLevel?this.resetNudgedMarkers():this.requestNudge()},l.getMarkers=function(){return this.markers.slice(0)},l.removeMarker=function(e){var i,r,n,s,o;if(null!=e._omsData&&this.unspiderfy(),i=this.arrIndexOf(this.markers,e),0>i)return this;for(o=this.markerListenerRefs.splice(i,1)[0],r=0,n=o.length;n>r;r++)s=o[r],t.removeListener(s);return delete e._oms,this.markers.splice(i,1),this.isNudgingActive()&&this.requestNudge(),this},l.clearMarkers=function(){var e,i,r,n,s,o,a,l,u;for(this.unspiderfy(),u=this.markers,e=i=0,n=u.length;n>i;e=++i){for(l=u[e],a=this.markerListenerRefs[e],r=0,s=a.length;s>r;r++)o=a[r],t.removeListener(o);delete l._oms}return this.initMarkerArrays(),this},l.addListener=function(e,t){var i;return(null!=(i=this.listeners)[e]?i[e]:i[e]=[]).push(t),this},l.removeListener=function(e,t){var i;return i=this.arrIndexOf(this.listeners[e],t),0>i||this.listeners[e].splice(i,1),this},l.clearListeners=function(e){return this.listeners[e]=[],this},l.trigger=function(){var e,t,i,n,s,o,a,l;for(t=arguments[0],e=arguments.length>=2?r.call(arguments,1):[],a=null!=(o=this.listeners[t])?o:[],l=[],n=0,s=a.length;s>n;n++)i=a[n],l.push(i.apply(null,e));return l},l.generatePtsCircle=function(e,t){var i,r,s,o,a,l,h,d;for(s=this.circleFootSeparation*(2+e),l=s/u,r=u/e,d=[],o=a=0,h=e;h>=0?h>a:a>h;o=h>=0?++a:--a)i=this.circleStartAngle+o*r,d.push(new n.Point(t.x+l*Math.cos(i),t.y+l*Math.sin(i)));return d},l.generatePtsSpiral=function(e,t){var i,r,s,o,a,l,h;for(o=this.spiralLengthStart,i=0,h=[],r=s=0,l=e;l>=0?l>s:s>l;r=l>=0?++s:--s)i+=this.spiralFootSeparation/o+5e-4*r,a=new n.Point(t.x+o*Math.cos(i),t.y+o*Math.sin(i)),o+=u*this.spiralLengthFactor/i,h.push(a);return h},l.spiderListener=function(e,t){var i,r,n,s,o,a,u,h,d,g,p,f,m;if(h=null!=e._omsData&&!e._omsData.nudged,h&&this.keepSpiderfied||("mouseover"===this.event?(i=this,r=function(){return i.unspiderfy()},window.clearTimeout(l.timeout),l.timeout=setTimeout(r,3e3)):this.unspiderfy()),h||this.map.getStreetView().getVisible()||"GoogleEarthAPI"===this.map.getMapTypeId())return this.trigger("click",e,t);for(g=[],p=[],d=this.nearbyDistance,f=d*d,u=this.llToPt(e.position),m=this.markers,n=0,s=m.length;s>n;n++)o=m[n],null!=o.map&&o.getVisible()&&(a=this.llToPt(o.position),this.ptDistanceSq(a,u)<f?g.push({marker:o,markerPt:a}):p.push(o));return 1===g.length?this.trigger("click",e,t):this.spiderfy(g,p)},l.markersNearMarker=function(e,t){var i,r,n,s,o,a,l,u,h,d,g;if(null==t&&(t=!1),null==this.projHelper.getProjection())throw"Must wait for 'idle' event on map before calling markersNearMarker";for(l=this.nearbyDistance,u=l*l,o=this.llToPt(e.position),a=[],h=this.markers,i=0,r=h.length;r>i&&(n=h[i],!(n!==e&&null!=n.map&&n.getVisible()&&(s=this.llToPt(null!=(d=null!=(g=n._omsData)?g.usualPosition:void 0)?d:n.position),this.ptDistanceSq(s,o)<u&&(a.push(n),t))));i++);return a},l.markersNearAnyOtherMarker=function(){var e,t,i,r,n,s,o,a,l,u,h,d,g,p,f,m,c,v,k,L,y;if(null==this.projHelper.getProjection())throw"Must wait for 'idle' event on map before calling markersNearAnyOtherMarker";for(m=this.nearbyDistance,c=m*m,p=function(){var e,t,i,r,n,s;for(i=this.markers,s=[],e=0,t=i.length;t>e;e++)l=i[e],s.push({pt:this.llToPt(null!=(r=null!=(n=l._omsData)?n.usualPosition:void 0)?r:l.position),willSpiderfy:!1});return s}.call(this),v=this.markers,t=r=0,s=v.length;s>r;t=++r)if(u=v[t],null!=u.map&&u.getVisible()&&(h=p[t],!h.willSpiderfy))for(k=this.markers,i=n=0,o=k.length;o>n;i=++n)if(d=k[i],i!==t&&null!=d.map&&d.getVisible()&&(g=p[i],(!(t>i)||g.willSpiderfy)&&this.ptDistanceSq(h.pt,g.pt)<c)){h.willSpiderfy=g.willSpiderfy=!0;break}for(L=this.markers,y=[],e=f=0,a=L.length;a>f;e=++f)l=L[e],p[e].willSpiderfy&&y.push(l);return y},l.makeHighlightListenerFuncs=function(e){return{highlight:function(t){return function(){var i;return e._omsData.leg.setOptions({strokeColor:t.legColors.highlighted[t.map.mapTypeId],zIndex:t.highlightedLegZIndex}),null!=e._omsData.shadow?(i=e._omsData.shadow.getIcon(),i.fillOpacity=.8,e._omsData.shadow.setOptions({icon:i})):void 0}}(this),unhighlight:function(t){return function(){var i;return e._omsData.leg.setOptions({strokeColor:t.legColors.usual[t.map.mapTypeId],zIndex:t.usualLegZIndex}),null!=e._omsData.shadow?(i=e._omsData.shadow.getIcon(),i.fillOpacity=.3,e._omsData.shadow.setOptions({icon:i})):void 0}}(this)}},l.spiderfy=function(e,i){var r,s,o,a,l,u,h,d,g,p,f,m,c;return this.minZoomLevel&&this.map.getZoom()<this.minZoomLevel?!1:(this.spiderfying=!0,m=e.length,r=this.ptAverage(function(){var t,i,r;for(r=[],t=0,i=e.length;i>t;t++)p=e[t],r.push(p.markerPt);return r}()),l=m>=this.circleSpiralSwitchover?this.generatePtsSpiral(m,r).reverse():this.generatePtsCircle(m,r),s=this.ptToLl(r),c=function(){var i,r,p,m,c;for(c=[],i=0,r=l.length;r>i;i++)a=l[i],o=this.ptToLl(a),f=this.minExtract(e,function(e){return function(t){return e.ptDistanceSq(t.markerPt,a)}}(this)),g=f.marker,d=this.lineToCenter?s:g.position,h=new n.Polyline({map:this.map,path:[d,o],strokeColor:this.legColors.usual[this.map.mapTypeId],strokeWeight:this.legWeight,zIndex:this.usualLegZIndex}),g._omsData={usualPosition:null!=(p=null!=(m=g._omsData)?m.usualPosition:void 0)?p:g.position,leg:h},this.spiderfiedShadowColor&&(g._omsData.shadow=new n.Marker({position:o,map:this.map,clickable:!1,zIndex:-2,icon:{path:google.maps.SymbolPath.CIRCLE,fillOpacity:.3,fillColor:this.spiderfiedShadowColor,strokeWeight:0,scale:20}})),this.legColors.highlighted[this.map.mapTypeId]!==this.legColors.usual[this.map.mapTypeId]&&(u=this.makeHighlightListenerFuncs(g),g._omsData.hightlightListeners={highlight:t.addListener(g,"mouseover",u.highlight),unhighlight:t.addListener(g,"mouseout",u.unhighlight)}),g.setPosition(o),g.setZIndex(Math.round(this.spiderfiedZIndex+a.y)),c.push(g);return c}.call(this),delete this.spiderfying,this.spiderfied=!0,this.trigger("spiderfy",c,i))},l.unspiderfy=function(e){var i,r,n,s,o,a,l,u;if(null==e&&(e=null),null==this.spiderfied)return this;for(this.unspiderfying=!0,u=[],o=[],a=this.markers,i=0,r=a.length;r>i;i++)s=a[i],null==s._omsData||s._omsData.nudged?o.push(s):(s._omsData.leg.setMap(null),null!=(l=s._omsData.shadow)&&l.setMap(null),s!==e&&s.setPosition(s._omsData.usualPosition),s.setZIndex(null),n=s._omsData.hightlightListeners,null!=n&&(t.removeListener(n.highlight),t.removeListener(n.unhighlight)),delete s._omsData,u.push(s));return delete this.unspiderfying,delete this.spiderfied,this.trigger("unspiderfy",u,o),this.nudged&&this.nudgeAllMarkers(),this},l.ptDistanceSq=function(e,t){var i,r;return i=e.x-t.x,r=e.y-t.y,i*i+r*r},l.ptAverage=function(e){var t,i,r,s,o,a;for(o=a=0,t=0,i=e.length;i>t;t++)s=e[t],o+=s.x,a+=s.y;return r=e.length,new n.Point(o/r,a/r)},l.llToPt=function(e){return this.projHelper.getProjection().fromLatLngToDivPixel(e)},l.ptToLl=function(e){return this.projHelper.getProjection().fromDivPixelToLatLng(e)},l.minExtract=function(e,t){var i,r,n,s,o,a,l;for(n=o=0,a=e.length;a>o;n=++o)s=e[n],l=t(s),("undefined"==typeof i||null===i||r>l)&&(r=l,i=n);return e.splice(i,1)[0]},l.arrIndexOf=function(e,t){var i,r,n,s;if(null!=e.indexOf)return e.indexOf(t);for(i=r=0,n=e.length;n>r;i=++r)if(s=e[i],s===t)return i;return-1},e.ProjHelper=function(e){return this.setMap(e)},e.ProjHelper.prototype=new n.OverlayView,e.ProjHelper.prototype.draw=function(){},e}(),e.exports=this.OverlappingMarkerSpiderfier}])});
var i={}.hasOwnProperty,r=[].slice;this.OverlappingMarkerSpiderfier=function(){function e(e,r){var n,s,o,l,a,u;this.map=e,null==r&&(r={});for(o in r)i.call(r,o)&&(u=r[o],this[o]=u);for(this.projHelper=new this.constructor.ProjHelper(this.map),this.initMarkerArrays(),this.listeners={},a=["click","zoom_changed","maptypeid_changed"],s=0,l=a.length;l>s;s++)n=a[s],t.addListener(this.map,n,function(e){return function(){return e.unspiderfy()}}(this));this.nudgeStackedMarkers&&t.addListenerOnce(this.map,"idle",function(e){return function(){return t.addListener(e.map,"zoom_changed",function(){return e.mapZoomChangeListener()}),e.mapZoomChangeListener()}}(this))}var t,n,s,o,l,a,u;return a=e.prototype,n=google.maps,t=n.event,l=n.MapTypeId,u=2*Math.PI,a.keepSpiderfied=!1,a.markersWontHide=!1,a.markersWontMove=!1,a.spiderfiedShadowColor="white",a.nudgeStackedMarkers=!0,a.minNudgeZoomLevel=8,a.nudgeRadius=1,a.markerCountInBaseNudgeLevel=9,a.maxNudgeCount=9,a.nudgeBucketSize=12,a.nearbyDistance=20,a.circleSpiralSwitchover=9,a.circleFootSeparation=23,a.circleStartAngle=u/12,a.spiralFootSeparation=26,a.spiralLengthStart=11,a.spiralLengthFactor=4,a.spiderfiedZIndex=1e3,a.usualLegZIndex=10,a.highlightedLegZIndex=20,a.event="click",a.minZoomLevel=!1,a.lineToCenter=!0,a.legWeight=1.5,a.legColors={usual:{},highlighted:{}},o=a.legColors.usual,s=a.legColors.highlighted,o[l.HYBRID]=o[l.SATELLITE]="#fff",s[l.HYBRID]=s[l.SATELLITE]="#f00",o[l.TERRAIN]=o[l.ROADMAP]="#444",s[l.TERRAIN]=s[l.ROADMAP]="#f00",a.initMarkerArrays=function(){return this.markers=[],this.markerListenerRefs=[]},a.addMarker=function(e){var i;return null!=e._oms?this:(e._oms=!0,i=[t.addListener(e,this.event,function(t){return function(i){return t.spiderListener(e,i)}}(this))],this.markersWontHide||i.push(t.addListener(e,"visible_changed",function(t){return function(){return t.markerChangeListener(e,!1)}}(this))),this.markersWontMove||i.push(t.addListener(e,"position_changed",function(t){return function(){return t.markerChangeListener(e,!0)}}(this))),this.markerListenerRefs.push(i),this.markers.push(e),this.isNudgingActive()&&this.requestNudge(),this)},a.nudgeTimeout=null,a.requestNudge=function(){return this.nudgeTimeout&&clearTimeout(this.nudgeTimeout),this.nudgeTimeout=setTimeout(function(e){return function(){return e.nudgeAllMarkers()}}(this),10)},a.isNudgingActive=function(){return this.nudgeStackedMarkers&&!(this.minNudgeZoomLevel&&this.map.getZoom()<this.minNudgeZoomLevel)&&!this.spiderfied},a.markerChangeListener=function(e,t){return null==e._omsData||!e._omsData.leg||!t&&e.getVisible()||null!=this.spiderfying||null!=this.unspiderfying?void 0:this.unspiderfy(t?e:null)},a.countsPerLevel=[1,1],a.levelsByCount=[],a.getCountPerNudgeLevel=function(e){return null!=this.countsPerLevel[e]?this.countsPerLevel[e]:this.countsPerLevel[e]=this.getCountPerNudgeLevel(e-1)+Math.pow(2,e-2)*this.markerCountInBaseNudgeLevel},a.getNudgeLevel=function(e){var t;if(null!=this.levelsByCount[e])return this.levelsByCount[e];for(t=0;e>=this.countsPerLevel[t];)t+1>=this.countsPerLevel.length&&this.getCountPerNudgeLevel(t+1),t++;return this.levelsByCount[e]=t-1},a.nudgeAllMarkers=function(){var e,t,i,r,n,s,o,l,a,h,d,g,p,f,m,c,v,k,L,y,P,D,_;if(this.isNudgingActive()){for(m={},r=[],n=[],e=1/((1+this.nudgeBucketSize)*this.nudgeRadius),o=function(t){return function(t){return Math.floor(t.x*e)+","+Math.floor(t.y*e)}}(this),c=this.markers,D=[],l=0,a=c.length;a>l;l++){for(h=c[l],d=!1,p=this.llToPt(null!=(v=null!=(k=h._omsData)?k.usualPosition:void 0)?v:h.position),g={x:p.x,y:p.y},f=o(p);null!=m[f]&&(null==this.maxNudgeCount||this.maxNudgeCount>=m[f]);)s=m[f],m[f]+=1,null!=r[s]?(t=r[s],i=n[s]):(_=this.getNudgeLevel(s),r[s]=t=20*Math.sin(u*s/this.markerCountInBaseNudgeLevel/_)*this.nudgeRadius*_,n[s]=i=20*Math.cos(u*s/this.markerCountInBaseNudgeLevel/_)*this.nudgeRadius*_),p.x=g.x+t,p.y=g.y+i,this.nudged=!0,d=!0,f=o(p);d?(h._omsData=null!=(L=h._omsData)?L:{},h._omsData.usualPosition=null!=(y=null!=(P=h._omsData)?P.usualPosition:void 0)?y:h.position,h.setPosition(this.ptToLl(p))):null!=h._omsData&&null==h._omsData.leg&&(h.setPosition(h._omsData.usualPosition),delete h._omsData),D.push(f in m?void 0:m[f]=1)}return D}},a.resetNudgedMarkers=function(){var e,t,i,r;if(this.nudged){for(r=this.markers,e=0,t=r.length;t>e;e++)i=r[e],null!=i._omsData&&null==i._omsData.leg&&(i.setPosition(i._omsData.usualPosition),delete i._omsData);return delete this.nudged}},a.mapZoomChangeListener=function(){return this.minNudgeZoomLevel&&this.map.getZoom()<this.minNudgeZoomLevel?this.resetNudgedMarkers():this.requestNudge()},a.getMarkers=function(){return this.markers.slice(0)},a.removeMarker=function(e){var i,r,n,s,o;if(null!=e._omsData&&this.unspiderfy(),i=this.arrIndexOf(this.markers,e),0>i)return this;for(o=this.markerListenerRefs.splice(i,1)[0],r=0,n=o.length;n>r;r++)s=o[r],t.removeListener(s);return delete e._oms,this.markers.splice(i,1),this.isNudgingActive()&&this.requestNudge(),this},a.clearMarkers=function(){var e,i,r,n,s,o,l,a,u;for(this.unspiderfy(),u=this.markers,e=i=0,n=u.length;n>i;e=++i){for(a=u[e],l=this.markerListenerRefs[e],r=0,s=l.length;s>r;r++)o=l[r],t.removeListener(o);delete a._oms}return this.initMarkerArrays(),this},a.addListener=function(e,t){var i;return(null!=(i=this.listeners)[e]?i[e]:i[e]=[]).push(t),this},a.removeListener=function(e,t){var i;return i=this.arrIndexOf(this.listeners[e],t),0>i||this.listeners[e].splice(i,1),this},a.clearListeners=function(e){return this.listeners[e]=[],this},a.trigger=function(){var e,t,i,n,s,o,l,a;for(t=arguments[0],e=arguments.length>=2?r.call(arguments,1):[],l=null!=(o=this.listeners[t])?o:[],a=[],n=0,s=l.length;s>n;n++)i=l[n],a.push(i.apply(null,e));return a},a.generatePtsCircle=function(e,t){var i,r,s,o,l,a,h,d;for(s=this.circleFootSeparation*(2+e),a=s/u,r=u/e,d=[],o=l=0,h=e;h>=0?h>l:l>h;o=h>=0?++l:--l)i=this.circleStartAngle+o*r,d.push(new n.Point(t.x+a*Math.cos(i),t.y+a*Math.sin(i)));return d},a.generatePtsSpiral=function(e,t){var i,r,s,o,l,a,h;for(o=this.spiralLengthStart,i=0,h=[],r=s=0,a=e;a>=0?a>s:s>a;r=a>=0?++s:--s)i+=this.spiralFootSeparation/o+5e-4*r,l=new n.Point(t.x+o*Math.cos(i),t.y+o*Math.sin(i)),o+=u*this.spiralLengthFactor/i,h.push(l);return h},a.spiderListener=function(e,t){var i,r,n,s,o,l,u,h,d,g,p;if(l=null!=e._omsData&&null!=e._omsData.leg,l&&this.keepSpiderfied||("mouseover"===this.event?(window.clearTimeout(a.timeout),a.timeout=setTimeout(function(e){return function(){return e.unspiderfy()}}(this),3e3)):this.unspiderfy()),l||this.map.getStreetView().getVisible()||"GoogleEarthAPI"===this.map.getMapTypeId())return this.trigger("click",e,t);for(h=[],d=[],u=this.nearbyDistance,g=u*u,o=this.llToPt(e.position),p=this.markers,i=0,r=p.length;r>i;i++)n=p[i],null!=n.map&&n.getVisible()&&(s=this.llToPt(n.position),this.ptDistanceSq(s,o)<g?h.push({marker:n,markerPt:s}):d.push(n));return 1===h.length?this.trigger("click",e,t):this.spiderfy(h,d)},a.markersNearMarker=function(e,t){var i,r,n,s,o,l,a,u,h,d,g;if(null==t&&(t=!1),null==this.projHelper.getProjection())throw"Must wait for 'idle' event on map before calling markersNearMarker";for(a=this.nearbyDistance,u=a*a,o=this.llToPt(e.position),l=[],h=this.markers,i=0,r=h.length;r>i&&(n=h[i],!(n!==e&&null!=n.map&&n.getVisible()&&(s=this.llToPt(null!=(d=null!=(g=n._omsData)?g.usualPosition:void 0)?d:n.position),this.ptDistanceSq(s,o)<u&&(l.push(n),t))));i++);return l},a.markersNearAnyOtherMarker=function(){var e,t,i,r,n,s,o,l,a,u,h,d,g,p,f,m,c,v,k,L,y;if(null==this.projHelper.getProjection())throw"Must wait for 'idle' event on map before calling markersNearAnyOtherMarker";for(m=this.nearbyDistance,c=m*m,p=function(){var e,t,i,r,n,s;for(i=this.markers,s=[],e=0,t=i.length;t>e;e++)a=i[e],s.push({pt:this.llToPt(null!=(r=null!=(n=a._omsData)?n.usualPosition:void 0)?r:a.position),willSpiderfy:!1});return s}.call(this),v=this.markers,t=r=0,s=v.length;s>r;t=++r)if(u=v[t],null!=u.map&&u.getVisible()&&(h=p[t],!h.willSpiderfy))for(k=this.markers,i=n=0,o=k.length;o>n;i=++n)if(d=k[i],i!==t&&null!=d.map&&d.getVisible()&&(g=p[i],(!(t>i)||g.willSpiderfy)&&this.ptDistanceSq(h.pt,g.pt)<c)){h.willSpiderfy=g.willSpiderfy=!0;break}for(L=this.markers,y=[],e=f=0,l=L.length;l>f;e=++f)a=L[e],p[e].willSpiderfy&&y.push(a);return y},a.makeHighlightListenerFuncs=function(e){return{highlight:function(t){return function(){var i;return e._omsData.leg.setOptions({strokeColor:t.legColors.highlighted[t.map.mapTypeId],zIndex:t.highlightedLegZIndex}),null!=e._omsData.shadow?(i=e._omsData.shadow.getIcon(),i.fillOpacity=.8,e._omsData.shadow.setOptions({icon:i})):void 0}}(this),unhighlight:function(t){return function(){var i;return e._omsData.leg.setOptions({strokeColor:t.legColors.usual[t.map.mapTypeId],zIndex:t.usualLegZIndex}),null!=e._omsData.shadow?(i=e._omsData.shadow.getIcon(),i.fillOpacity=.3,e._omsData.shadow.setOptions({icon:i})):void 0}}(this)}},a.spiderfy=function(e,i){var r,s,o,l,a,u,h,d,g,p,f,m,c;return this.minZoomLevel&&this.map.getZoom()<this.minZoomLevel?!1:(this.spiderfying=!0,m=e.length,r=this.ptAverage(function(){var t,i,r;for(r=[],t=0,i=e.length;i>t;t++)p=e[t],r.push(p.markerPt);return r}()),a=m>=this.circleSpiralSwitchover?this.generatePtsSpiral(m,r).reverse():this.generatePtsCircle(m,r),s=this.ptToLl(r),c=function(){var i,r,p,m,c,v;for(v=[],i=0,r=a.length;r>i;i++)l=a[i],o=this.ptToLl(l),f=this.minExtract(e,function(e){return function(t){return e.ptDistanceSq(t.markerPt,l)}}(this)),g=f.marker,d=this.lineToCenter?s:g.position,h=new n.Polyline({map:this.map,path:[d,o],strokeColor:this.legColors.usual[this.map.mapTypeId],strokeWeight:this.legWeight,zIndex:this.usualLegZIndex}),g._omsData=null!=(p=g._omsData)?p:{},g._omsData.usualPosition=null!=(m=null!=(c=g._omsData)?c.usualPosition:void 0)?m:g.position,g._omsData.leg=h,this.spiderfiedShadowColor&&(g._omsData.shadow=new n.Marker({position:o,map:this.map,clickable:!1,zIndex:-2,icon:{path:google.maps.SymbolPath.CIRCLE,fillOpacity:.3,fillColor:this.spiderfiedShadowColor,strokeWeight:0,scale:20}})),this.legColors.highlighted[this.map.mapTypeId]!==this.legColors.usual[this.map.mapTypeId]&&(u=this.makeHighlightListenerFuncs(g),g._omsData.hightlightListeners={highlight:t.addListener(g,"mouseover",u.highlight),unhighlight:t.addListener(g,"mouseout",u.unhighlight)}),g.setPosition(o),g.setZIndex(Math.round(this.spiderfiedZIndex+l.y)),v.push(g);return v}.call(this),delete this.spiderfying,this.spiderfied=!0,this.trigger("spiderfy",c,i))},a.unspiderfy=function(e){var i,r,n,s,o,l,a,u;if(null==e&&(e=null),null==this.spiderfied&&null==this.nudged)return this;for(this.unspiderfying=!0,u=[],o=[],l=this.markers,i=0,r=l.length;r>i;i++)s=l[i],null!=s._omsData&&null!=s._omsData.leg?(s._omsData.leg.setMap(null),null!=(a=s._omsData.shadow)&&a.setMap(null),s!==e&&s.setPosition(s._omsData.usualPosition),s.setZIndex(null),n=s._omsData.hightlightListeners,null!=n&&(t.removeListener(n.highlight),t.removeListener(n.unhighlight)),delete s._omsData,u.push(s)):o.push(s);return delete this.unspiderfying,delete this.spiderfied,this.trigger("unspiderfy",u,o),this.nudged&&this.requestNudge(),this},a.ptDistanceSq=function(e,t){var i,r;return i=e.x-t.x,r=e.y-t.y,i*i+r*r},a.ptAverage=function(e){var t,i,r,s,o,l;for(o=l=0,t=0,i=e.length;i>t;t++)s=e[t],o+=s.x,l+=s.y;return r=e.length,new n.Point(o/r,l/r)},a.llToPt=function(e){return this.projHelper.getProjection().fromLatLngToDivPixel(e)},a.ptToLl=function(e){return this.projHelper.getProjection().fromDivPixelToLatLng(e)},a.minExtract=function(e,t){var i,r,n,s,o,l,a;for(n=o=0,l=e.length;l>o;n=++o)s=e[n],a=t(s),("undefined"==typeof i||null===i||r>a)&&(r=a,i=n);return e.splice(i,1)[0]},a.arrIndexOf=function(e,t){var i,r,n,s;if(null!=e.indexOf)return e.indexOf(t);for(i=r=0,n=e.length;n>r;i=++r)if(s=e[i],s===t)return i;return-1},e.ProjHelper=function(e){return this.setMap(e)},e.ProjHelper.prototype=new n.OverlayView,e.ProjHelper.prototype.draw=function(){},e}(),e.exports=this.OverlappingMarkerSpiderfier}])});

@@ -179,7 +179,7 @@ // Generated by CoffeeScript 1.10.0

p.isNudgingActive = function() {
return this['nudgeStackedMarkers'] && !(this['minNudgeZoomLevel'] && this.map.getZoom() < this['minNudgeZoomLevel']);
return this['nudgeStackedMarkers'] && !(this['minNudgeZoomLevel'] && this.map.getZoom() < this['minNudgeZoomLevel']) && !this.spiderfied;
};
p.markerChangeListener = function(marker, positionChanged) {
if ((marker['_omsData'] != null) && !marker['_omsData'].nudged && (positionChanged || !marker.getVisible()) && !((this.spiderfying != null) || (this.unspiderfying != null))) {
if ((marker['_omsData'] != null) && marker['_omsData'].leg && (positionChanged || !marker.getVisible()) && !((this.spiderfying != null) || (this.unspiderfying != null))) {
return this['unspiderfy'](positionChanged ? marker : null);

@@ -218,3 +218,3 @@ }

p.nudgeAllMarkers = function() {
var bucketSize, changeX, changeY, changesX, changesY, count, getHash, j, len, m, needsNudge, originalPos, pos, posHash, positions, ref, ref1, ref2, ref3, ref4, results, ringLevel;
var bucketSize, changeX, changeY, changesX, changesY, count, getHash, j, len, m, needsNudge, originalPos, pos, posHash, positions, ref, ref1, ref2, ref3, ref4, ref5, results, ringLevel;
if (!this.isNudgingActive()) {

@@ -261,8 +261,6 @@ return;

if (needsNudge) {
m['_omsData'] = {
usualPosition: (ref3 = (ref4 = m['_omsData']) != null ? ref4.usualPosition : void 0) != null ? ref3 : m.position,
nudged: true
};
m['_omsData'] = (ref3 = m['_omsData']) != null ? ref3 : {};
m['_omsData'].usualPosition = (ref4 = (ref5 = m['_omsData']) != null ? ref5.usualPosition : void 0) != null ? ref4 : m.position;
m.setPosition(this.ptToLl(pos));
} else if ((m['_omsData'] != null) && m['_omsData'].nudged) {
} else if ((m['_omsData'] != null) && (m['_omsData'].leg == null)) {
m.setPosition(m['_omsData'].usualPosition);

@@ -288,3 +286,3 @@ delete m['_omsData'];

m = ref[j];
if ((m['_omsData'] != null) && m['_omsData'].nudged) {
if ((m['_omsData'] != null) && (m['_omsData'].leg == null)) {
m.setPosition(m['_omsData'].usualPosition);

@@ -407,12 +405,12 @@ delete m['_omsData'];

p.spiderListener = function(marker, event) {
var $this, clear, j, len, m, mPt, markerPt, markerSpiderfied, nDist, nearbyMarkerData, nonNearbyMarkers, pxSq, ref;
markerSpiderfied = (marker['_omsData'] != null) && !marker['_omsData'].nudged;
var j, len, m, mPt, markerPt, markerSpiderfied, nDist, nearbyMarkerData, nonNearbyMarkers, pxSq, ref;
markerSpiderfied = (marker['_omsData'] != null) && (marker['_omsData'].leg != null);
if (!(markerSpiderfied && this['keepSpiderfied'])) {
if (this['event'] === 'mouseover') {
$this = this;
clear = function() {
return $this['unspiderfy']();
};
window.clearTimeout(p.timeout);
p.timeout = setTimeout(clear, 3000);
p.timeout = setTimeout((function(_this) {
return function() {
return _this['unspiderfy']();
};
})(this), 3000);
} else {

@@ -599,3 +597,3 @@ this['unspiderfy']();

spiderfiedMarkers = (function() {
var j, len, ref, ref1, results;
var j, len, ref, ref1, ref2, results;
results = [];

@@ -619,6 +617,5 @@ for (j = 0, len = footPts.length; j < len; j++) {

});
marker['_omsData'] = {
usualPosition: (ref = (ref1 = marker['_omsData']) != null ? ref1.usualPosition : void 0) != null ? ref : marker.position,
leg: leg
};
marker['_omsData'] = (ref = marker['_omsData']) != null ? ref : {};
marker['_omsData'].usualPosition = (ref1 = (ref2 = marker['_omsData']) != null ? ref2.usualPosition : void 0) != null ? ref1 : marker.position;
marker['_omsData'].leg = leg;
if (this['spiderfiedShadowColor']) {

@@ -662,3 +659,3 @@ marker['_omsData'].shadow = new gm.Marker({

}
if (this.spiderfied == null) {
if (!((this.spiderfied != null) || (this.nudged != null))) {
return this;

@@ -672,3 +669,3 @@ }

marker = ref[j];
if ((marker['_omsData'] != null) && !marker['_omsData'].nudged) {
if ((marker['_omsData'] != null) && (marker['_omsData'].leg != null)) {
marker['_omsData'].leg.setMap(null);

@@ -697,3 +694,3 @@ if ((ref1 = marker['_omsData'].shadow) != null) {

if (this.nudged) {
this.nudgeAllMarkers();
this.requestNudge();
}

@@ -700,0 +697,0 @@ return this;

{
"name": "overlapping-marker-spiderfier",
"version": "1.1.2",
"version": "1.1.3",
"description": "Deals with overlapping markers in Google Maps JS API v3, Google Earth-style",

@@ -5,0 +5,0 @@ "main": "lib/oms.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet