/*! * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */function inherits(childCtor,parentCtor){function tempCtor(){};tempCtor.prototype=parentCtor.prototype;childCtor.superClass_=parentCtor.prototype;childCtor.prototype=new tempCtor();childCtor.prototype.constructor=childCtor;} function MarkerLabel_(marker,crossURL,handCursorURL){this.marker_=marker;this.handCursorURL_=marker.handCursorURL;this.labelDiv_=document.createElement("div");this.labelDiv_.style.cssText="position: absolute; overflow: hidden;";this.eventDiv_=document.createElement("div");this.eventDiv_.style.cssText=this.labelDiv_.style.cssText;this.eventDiv_.setAttribute("onselectstart","return false;");this.eventDiv_.setAttribute("ondragstart","return false;");this.crossDiv_=MarkerLabel_.getSharedCross(crossURL);} inherits(MarkerLabel_,google.maps.OverlayView);MarkerLabel_.getSharedCross=function(crossURL){var div;if(typeof MarkerLabel_.getSharedCross.crossDiv==="undefined"){div=document.createElement("img");div.style.cssText="position: absolute; z-index: 1000002; display: none;";div.style.marginLeft="-8px";div.style.marginTop="-9px";div.src=crossURL;MarkerLabel_.getSharedCross.crossDiv=div;} return MarkerLabel_.getSharedCross.crossDiv;};MarkerLabel_.prototype.onAdd=function(){var me=this;var cMouseIsDown=false;var cDraggingLabel=false;var cSavedZIndex;var cLatOffset,cLngOffset;var cIgnoreClick;var cRaiseEnabled;var cStartPosition;var cStartCenter;var cRaiseOffset=20;var cDraggingCursor="url("+this.handCursorURL_+")";var cAbortEvent=function(e){if(e.preventDefault){e.preventDefault();} e.cancelBubble=true;if(e.stopPropagation){e.stopPropagation();}};var cStopBounce=function(){me.marker_.setAnimation(null);};this.getPanes().overlayImage.appendChild(this.labelDiv_);this.getPanes().overlayMouseTarget.appendChild(this.eventDiv_);if(typeof MarkerLabel_.getSharedCross.processed==="undefined"){this.getPanes().overlayImage.appendChild(this.crossDiv_);MarkerLabel_.getSharedCross.processed=true;} this.listeners_=[google.maps.event.addDomListener(this.eventDiv_,"mouseover",function(e){if(me.marker_.getDraggable()||me.marker_.getClickable()){this.style.cursor="pointer";google.maps.event.trigger(me.marker_,"mouseover",e);}}),google.maps.event.addDomListener(this.eventDiv_,"mouseout",function(e){if((me.marker_.getDraggable()||me.marker_.getClickable())&&!cDraggingLabel){this.style.cursor=me.marker_.getCursor();google.maps.event.trigger(me.marker_,"mouseout",e);}}),google.maps.event.addDomListener(this.eventDiv_,"mousedown",function(e){cDraggingLabel=false;if(me.marker_.getDraggable()){cMouseIsDown=true;this.style.cursor=cDraggingCursor;} if(me.marker_.getDraggable()||me.marker_.getClickable()){google.maps.event.trigger(me.marker_,"mousedown",e);cAbortEvent(e);}}),google.maps.event.addDomListener(document,"mouseup",function(mEvent){var position;if(cMouseIsDown){cMouseIsDown=false;me.eventDiv_.style.cursor="pointer";google.maps.event.trigger(me.marker_,"mouseup",mEvent);} if(cDraggingLabel){if(cRaiseEnabled){position=me.getProjection().fromLatLngToDivPixel(me.marker_.getPosition());position.y+=cRaiseOffset;me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));try{me.marker_.setAnimation(google.maps.Animation.BOUNCE);setTimeout(cStopBounce,1406);}catch(e){}} me.crossDiv_.style.display="none";me.marker_.setZIndex(cSavedZIndex);cIgnoreClick=true;cDraggingLabel=false;mEvent.latLng=me.marker_.getPosition();google.maps.event.trigger(me.marker_,"dragend",mEvent);}}),google.maps.event.addListener(me.marker_.getMap(),"mousemove",function(mEvent){var position;if(cMouseIsDown){if(cDraggingLabel){mEvent.latLng=new google.maps.LatLng(mEvent.latLng.lat()-cLatOffset,mEvent.latLng.lng()-cLngOffset);position=me.getProjection().fromLatLngToDivPixel(mEvent.latLng);if(cRaiseEnabled){me.crossDiv_.style.left=position.x+"px";me.crossDiv_.style.top=position.y+"px";me.crossDiv_.style.display="";position.y-=cRaiseOffset;} me.marker_.setPosition(me.getProjection().fromDivPixelToLatLng(position));if(cRaiseEnabled){me.eventDiv_.style.top=(position.y+cRaiseOffset)+"px";} google.maps.event.trigger(me.marker_,"drag",mEvent);}else{cLatOffset=mEvent.latLng.lat()-me.marker_.getPosition().lat();cLngOffset=mEvent.latLng.lng()-me.marker_.getPosition().lng();cSavedZIndex=me.marker_.getZIndex();cStartPosition=me.marker_.getPosition();cStartCenter=me.marker_.getMap().getCenter();cRaiseEnabled=me.marker_.get("raiseOnDrag");cDraggingLabel=true;me.marker_.setZIndex(1000000);mEvent.latLng=me.marker_.getPosition();google.maps.event.trigger(me.marker_,"dragstart",mEvent);}}}),google.maps.event.addDomListener(document,"keydown",function(e){if(cDraggingLabel){if(e.keyCode===27){cRaiseEnabled=false;me.marker_.setPosition(cStartPosition);me.marker_.getMap().setCenter(cStartCenter);google.maps.event.trigger(document,"mouseup",e);}}}),google.maps.event.addDomListener(this.eventDiv_,"click",function(e){if(me.marker_.getDraggable()||me.marker_.getClickable()){if(cIgnoreClick){cIgnoreClick=false;}else{google.maps.event.trigger(me.marker_,"click",e);cAbortEvent(e);}}}),google.maps.event.addDomListener(this.eventDiv_,"dblclick",function(e){if(me.marker_.getDraggable()||me.marker_.getClickable()){google.maps.event.trigger(me.marker_,"dblclick",e);cAbortEvent(e);}}),google.maps.event.addListener(this.marker_,"dragstart",function(mEvent){if(!cDraggingLabel){cRaiseEnabled=this.get("raiseOnDrag");}}),google.maps.event.addListener(this.marker_,"drag",function(mEvent){if(!cDraggingLabel){if(cRaiseEnabled){me.setPosition(cRaiseOffset);me.labelDiv_.style.zIndex=1000000+(this.get("labelInBackground")?-1:+1);}}}),google.maps.event.addListener(this.marker_,"dragend",function(mEvent){if(!cDraggingLabel){if(cRaiseEnabled){me.setPosition(0);}}}),google.maps.event.addListener(this.marker_,"position_changed",function(){me.setPosition();}),google.maps.event.addListener(this.marker_,"zindex_changed",function(){me.setZIndex();}),google.maps.event.addListener(this.marker_,"visible_changed",function(){me.setVisible();}),google.maps.event.addListener(this.marker_,"labelvisible_changed",function(){me.setVisible();}),google.maps.event.addListener(this.marker_,"title_changed",function(){me.setTitle();}),google.maps.event.addListener(this.marker_,"labelcontent_changed",function(){me.setContent();}),google.maps.event.addListener(this.marker_,"labelanchor_changed",function(){me.setAnchor();}),google.maps.event.addListener(this.marker_,"labelclass_changed",function(){me.setStyles();}),google.maps.event.addListener(this.marker_,"labelstyle_changed",function(){me.setStyles();})];};MarkerLabel_.prototype.onRemove=function(){var i;this.labelDiv_.parentNode.removeChild(this.labelDiv_);this.eventDiv_.parentNode.removeChild(this.eventDiv_);for(i=0;i