Changeset 12698 for extensions/rv_gmaps/trunk/template/data_handler.js
- Timestamp:
- Dec 6, 2011, 5:42:24 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/template/data_handler.js
r8724 r12698 3 3 { 4 4 this._map = map; 5 this._infoWindow = new google.maps.InfoWindow(); 5 6 this.options = jQuery.fn.extend( 6 7 { 7 icon: G_DEFAULT_ICON,8 markerOptions: {}, 8 9 show_all_img_src: null 9 10 } 10 11 , opts || {} ); 11 12 12 google.maps. Event.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} );13 google.maps.event.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} ); 13 14 } 14 15 … … 16 17 17 18 _map: null, 19 _infoWindow: null, 18 20 options: {}, 19 21 _markers: [], … … 60 62 { 61 63 changed = false; 62 if (this._markers.length>0 && !this._markers[0].get LatLng().equals( data.image_clusters[0].position ) )64 if (this._markers.length>0 && !this._markers[0].getPosition().equals( data.image_clusters[0].position ) ) 63 65 changed=true; 64 66 } … … 67 69 { 68 70 var newMarkers = []; 69 var infoWindowMarker = this._ map.getInfoWindow().pwgMarker;71 var infoWindowMarker = this._infoWindow.pwgMarker; 70 72 71 73 for (i=0; i<data.image_clusters.length; i++) … … 82 84 if (marker && marker==infoWindowMarker) 83 85 { 84 this._map.removeOverlay( marker);85 google.maps. Event.clearListeners(marker, "click" );86 google.maps. Event.clearListeners(marker, "dblclick" );87 this._ map.getInfoWindow().pwgMarker = infoWindowMarker = null;88 if (document.is_debug) g oogle.maps.Log.write('removed marker with infoWindow');86 marker.setMap(null); 87 google.maps.event.clearListeners(marker, "click" ); 88 google.maps.event.clearListeners(marker, "dblclick" ); 89 this._infoWindow.pwgMarker = infoWindowMarker = null; 90 if (document.is_debug) glog('removed marker with infoWindow'); 89 91 marker = this._markers.pop(); 90 92 } … … 92 94 if (!marker) 93 95 { 94 marker = new google.maps.Marker( cluster.position, {title: theTitle, icon: this.options.icon } ); 95 google.maps.Event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) ); 96 google.maps.Event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) ); 97 this._map.addOverlay( marker ); 96 marker = new google.maps.Marker(this.options.markerOptions); 97 marker.setPosition(cluster.position); 98 marker.setTitle(theTitle); 99 google.maps.event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) ); 100 google.maps.event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) ); 101 marker.setMap(this._map); 98 102 } 99 103 else 100 104 { 101 105 marker.currentImageIndex=0; 102 marker.setLatLng( cluster.position ); 103 // changing the marker title is undocumented so we hack it 104 if (!this.hack) 105 { 106 this.hack = {}; 107 for (var prop in marker) 108 { 109 if ( typeof(marker[prop])!='object') continue; 110 if (!this.hack.markerHtmlElemWithTitle ) 111 { 112 try { 113 if (eval("typeof marker." + prop + "[0].src") == "string" && eval("typeof marker." + prop + "[0].title") == "string" ) 114 this.hack.markerHtmlElemWithTitle = prop; 115 } 116 catch (e) {} 117 } 118 if (!this.hack.markerOptions) 119 try { 120 if ( eval("typeof marker."+prop+".title")=="string" && eval("typeof marker."+prop+".src")=="undefined") 121 this.hack.markerOptions = prop; 122 } 123 catch (e) {} 124 } 125 } 126 //undocumented marker.K , marker.ch and marker.jb and marker.l 127 if (this.hack.markerOptions) 128 eval( 'marker.'+this.hack.markerOptions+'.title=theTitle'); 129 if (this.hack.markerHtmlElemWithTitle) 130 eval( 'marker.'+this.hack.markerHtmlElemWithTitle+'[0].title=theTitle'); 106 marker.setPosition( cluster.position ); 107 marker.setTitle(theTitle); 108 marker.setMap(this._map); 131 109 } 132 110 … … 143 121 for (i=0; i<this._markers.length; i++) 144 122 { 145 this._ma p.removeOverlay( this._markers[i]);146 google.maps. Event.clearListeners(this._markers[i], "click" );147 google.maps. Event.clearListeners(this._markers[i], "dblclick" );123 this._markers[i].setMap(null); 124 google.maps.event.clearListeners(this._markers[i], "click" ); 125 google.maps.event.clearListeners(this._markers[i], "dblclick" ); 148 126 } 149 127 … … 158 136 _onMarkerClick: function( marker ) 159 137 { 160 if (this._ map.getInfoWindow().pwgMarker == marker )138 if (this._infoWindow.pwgMarker == marker ) 161 139 return; // already open 162 140 var content = ""; … … 182 160 content += '<div id="pwgImageDetail">' + this.buildCurrentPictureHtml( marker ) + '</div>'; 183 161 184 marker.openInfoWindowHtml( content ); 162 this._infoWindow.setContent( content ); 163 this._infoWindow.setPosition( marker.getPosition() ); 164 this._infoWindow.open( this._map ); 185 165 186 166 // bind to next / prev a little later because sometimes the nodes are not immediately created … … 193 173 _onMarkerDblClick: function( marker ) 194 174 { 195 this._map. setCenter( marker.pwg.bounds.getCenter(), this._map.getBoundsZoomLevel( marker.pwg.bounds ));175 this._map.fitBounds( marker.pwg.bounds ); 196 176 }, 197 177 … … 228 208 clearTimeout(this._timerBindPictureNavigation); 229 209 this._timerBindPictureNavigation = null; 230 this._ map.getInfoWindow().pwgMarker = marker;210 this._infoWindow.pwgMarker = marker; 231 211 for (var i=0; i< this._navHtmlIds.length; i++) 232 212 { 233 213 var elt = document.getElementById( this._navHtmlIds[i] ); 234 214 if (elt) 235 google.maps. Event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, marker, i) );215 google.maps.event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, marker, i) ); 236 216 } 237 217 },
Note: See TracChangeset
for help on using the changeset viewer.