Changeset 12698 for extensions/rv_gmaps
- Timestamp:
- Dec 6, 2011, 5:42:24 AM (12 years ago)
- Location:
- extensions/rv_gmaps/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/map.php
r8304 r12698 84 84 } 85 85 else 86 $template->assign('MAP_MARKER_ICON_JS', 'return G_DEFAULT_ICON;');86 $template->assign('MAP_MARKER_ICON_JS', 'return {}'); 87 87 88 88 $template->pparse('map'); -
extensions/rv_gmaps/trunk/map_data.php
r7388 r12698 63 63 function jsgm_position( $position ) 64 64 { 65 return 'new GLatLng(' . $position['lat'] . ',' . $position['lon'] . ')';65 return 'new google.maps.LatLng(' . $position['lat'] . ',' . $position['lon'] . ')'; 66 66 } 67 67 68 68 function jsgm_bounds( $bounds ) 69 69 { 70 return 'new GLatLngBounds(' . jsgm_position(bounds_sw($bounds)) . ',' . jsgm_position(bounds_ne($bounds)) . ')';70 return 'new google.maps.LatLngBounds(' . jsgm_position(bounds_sw($bounds)) . ',' . jsgm_position(bounds_ne($bounds)) . ')'; 71 71 } 72 72 -
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 }, -
extensions/rv_gmaps/trunk/template/data_loader.js
r8221 r12698 4 4 this.options = jQuery.fn.extend( 5 5 { 6 reload_data_timeout: 1800,7 rectangle_of_confusion: G_DEFAULT_ICON.iconSize6 reload_data_timeout: 500, 7 rectangle_of_confusion: new google.maps.Size(32,16) 8 8 } 9 9 , opts || {} ); … … 37 37 { 38 38 this._urlMapData = urlMapData; 39 google.maps. Event.bind( this._map, "movestart", this, this.clearTimerReloadData );40 google.maps. Event.bind( this._map, "moveend", this, this._onMapMoveEnd);41 this._loadData();39 google.maps.event.bind( this._map, "movestart", this, this.clearTimerReloadData ); 40 google.maps.event.bind( this._map, "idle", this, this._onIdle ); 41 //this._loadData(); 42 42 }, 43 43 … … 59 59 }, 60 60 61 _on MapMoveEnd: function()61 _onIdle: function() 62 62 { 63 63 this.clearTimerReloadData(); … … 78 78 79 79 var latRange = bounds.toSpan().lat(); 80 var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.get Size().height;80 var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getDiv().offsetHeight; 81 81 82 82 var lonRange = bounds.toSpan().lng(); 83 var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.get Size().width;83 var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.getDiv().offsetWidth; 84 84 85 85 if ( this._previousLoadDataReq.box!=null ) 86 86 { // not the first time 87 if ( this._previousLoadDataReq.box.containsBounds( bounds ) ) 87 if ( this._previousLoadDataReq.box.contains( bounds.getNorthEast() ) 88 && this._previousLoadDataReq.box.contains( bounds.getSouthWest() )) 88 89 { 89 90 if ( this._previousLoadDataReq.resultBounds == null ) … … 109 110 110 111 var nd=0, sd=0, ed=0, wd=0; 111 if ( !bounds.isFullLat() )112 /*if ( !bounds.isFullLat() )*/ 112 113 { 113 114 nd = latRange*12/100; 114 115 sd = latRange*4/100; 115 116 } 116 if ( !bounds.isFullLng() )117 /*if ( !bounds.isFullLng() )*/ 117 118 { 118 119 ed = lonRange*9/100; … … 130 131 131 132 if (document.is_debug) { 132 google.maps.Log.write("sd="+sd+" wd="+wd+" nd="+nd+" ed="+ed); 133 google.maps.Log.write( "bounds: " + this._map.getBounds().getSouthWest().toUrlValue() + " " + this._map.getBounds().getNorthEast().toUrlValue() +"; zoom: "+this._map.getZoom() +"; size: "+this._map.getSize().toString() +"; c: "+this._map.getCenter().toUrlValue() ); 134 google.maps.Log.writeUrl( url ); 133 glog("sd="+sd+" wd="+wd+" nd="+nd+" ed="+ed); 134 glog( url ); 135 135 } 136 136 … … 141 141 142 142 try { 143 google.maps. Event.trigger( this, "dataloading" );143 google.maps.event.trigger( this, "dataloading" ); 144 144 jQuery.ajax( { 145 145 url: url, … … 151 151 this._dataLoading = false; 152 152 this._previousLoadDataReq.box=null; 153 google.maps. Event.trigger( this, "dataloadfailed", 600, e );153 google.maps.event.trigger( this, "dataloadfailed", 600, e ); 154 154 } 155 155 }, … … 164 164 throw new Error( "DATA DECODING ERROR" ); 165 165 this._previousLoadDataReq.resultBounds = resp.bounds; 166 if (document.is_debug && resp.debug) g oogle.maps.Log.write( resp.debug );167 google.maps. Event.trigger( this, "dataloaded", resp );166 if (document.is_debug && resp.debug) glog( resp.debug ); 167 google.maps.event.trigger( this, "dataloaded", resp ); 168 168 } 169 169 catch (e) { 170 170 this._previousLoadDataReq.box=null; 171 google.maps. Event.trigger( this, "dataloadfailed", responseCode, e );171 google.maps.event.trigger( this, "dataloadfailed", responseCode, e ); 172 172 var s = e.message; 173 173 s += '\n' + data.substr(0,1000); … … 182 182 { 183 183 try { 184 google.maps. Event.trigger( this, "dataloadfailed", textStatus + xhr.status, exc );184 google.maps.event.trigger( this, "dataloadfailed", textStatus + xhr.status, exc ); 185 185 } 186 186 catch (e) { -
extensions/rv_gmaps/trunk/template/map.tpl
r12367 r12698 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">1 <!DOCTYPE html> 2 2 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 3 3 <head> 4 4 <meta http-equiv="content-type" content="text/html; charset={$CONTENT_ENCODING}" /> 5 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 5 6 <meta name="robots" content="noindex,nofollow" /> 6 7 <title>{$GALLERY_TITLE}</title> 7 8 8 <script src="http://maps.google .com/maps?file=api&v=2&key={$GMAPS_API_KEY}&hl={$lang_info.code}" type="text/javascript"></script>9 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language={$lang_info.code}" type="text/javascript"></script> 9 10 10 11 {combine_script id='jquery' load='header' path='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'} … … 46 47 document._window = window; 47 48 } 48 49 50 function glog(msg) { 51 if (console) 52 { 53 console.debug(msg + " b="+map.getBounds().toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() ); 54 } 55 } 56 49 57 function load() 50 58 { 51 if (!GBrowserIsCompatible()) 52 return; 53 54 var mapElement = document.getElementById("map"); 55 map = new google.maps.Map2( mapElement ); 56 57 map.addMapType( G_PHYSICAL_MAP ); 58 map.addControl(new google.maps.LargeMapControl3D()); 59 map.addControl(new google.maps.HierarchicalMapTypeControl()); 60 map.addControl(new google.maps.ScaleControl()); 61 62 pwgPageLinker = new PageLinker(map, "aLinkToThisPage" ); 63 if ( !map.isLoaded() ) 59 var mapOptions = { 60 mapTypeId: google.maps.MapTypeId.ROADMAP, 61 overviewMapControl: true 62 } 63 64 if (1/*!PageLinker.url2Map(mapOptions)*/) 64 65 { 65 66 {/literal} 66 67 {if isset($initial_bounds)} 67 var bounds = new google.maps.LatLngBounds( new google.maps.LatLng({$initial_bounds.s},{$initial_bounds.w}), new google.maps.LatLng({$initial_bounds.n},{$initial_bounds.e}) ); 68 map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel( bounds ) ); 68 mapOptions.iniBounds = new google.maps.LatLngBounds( new google.maps.LatLng({$initial_bounds.s},{$initial_bounds.w}), new google.maps.LatLng({$initial_bounds.n},{$initial_bounds.e}) ); 69 mapOptions.center = mapOptions.iniBounds.getCenter(); 70 {else} 71 mapOptions.center = new google.maps.LatLng(0,0); 72 mapOptions.zoom = 2; 69 73 {/if} 70 74 {literal} 71 if ( !map.isLoaded() ) 72 map.setCenter( new google.maps.LatLng(0,0), 2 ); 73 } 74 75 try { 76 // the overview must be added after setting map center 77 var ovcontrol = new google.maps.OverviewMapControl(new google.maps.Size(165,165)); 78 map.addControl(ovcontrol); 79 } 80 catch(e){ alert( e.message ); } 81 82 map.enableScrollWheelZoom(); 83 map.enableDoubleClickZoom(); 84 85 var pwgMarkerIcon = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null); 86 87 map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerIcon.iconSize} ); 88 google.maps.Event.addListener(map.pwgDataLoader, "dataloading", function() { 75 } 76 77 map = new google.maps.Map( document.getElementById("map"), mapOptions ); 78 79 if (mapOptions.iniBounds) 80 map.fitBounds(mapOptions.iniBounds); 81 82 if (document.is_debug) 83 { 84 google.maps.event.addListener(map, "idle", function() { glog("idle"); }); 85 google.maps.event.addListener(map, "bounds_changed", function() { glog("bounds_changed");} ); 86 google.maps.event.addListener(map, "center_changed", function() { glog("center_changed");} ); 87 google.maps.event.addListener(map, "maptypeid_changed", function() { glog("maptypeid_changed");} ); 88 google.maps.event.addListener(map, "zoom_changed", function() { glog("zoom_changed");} ); 89 google.maps.event.addListener(map, "drag", function() { glog("drag");} ); 90 } 91 92 pwgPageLinker = new PageLinker(map, "aLinkToThisPage" ); 93 94 var pwgMarkerOptions = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null); 95 96 map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerOptions.roc} ); 97 google.maps.event.addListener(map.pwgDataLoader, "dataloading", function() { 89 98 var pre = '<img src="{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/progress_s.gif" width="16" height="16" alt="~" /> '; 90 99 document.getElementById("dataLoadStatus").innerHTML = pre + Localization.get("Loading"); … … 92 101 ); 93 102 94 google.maps. Event.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) {103 google.maps.event.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) { 95 104 document.getElementById("dataLoadStatus").innerHTML = Localization.get("Failed") + " "+responseCode; 96 105 } 97 106 ); 98 107 99 map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarker Icon, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );100 google.maps. Event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) );108 map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarkerOptions, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } ); 109 google.maps.event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) ); 101 110 102 111 map.pwgDataLoader.start( "{/literal}{$U_MAP_DATA}{literal}" ); 103 104 if (document.is_debug)105 {106 google.maps.Event.addListener(map, "moveend", function() { google.maps.Log.write("movend c:"+map.getCenter().toUrlValue());} );107 google.maps.Event.addListener(map, "maptypechanged", function() { google.maps.Log.write("maptypechanged");} );108 google.maps.Event.addListener(map, "infowindowopen", function() { google.maps.Log.write("infowindowopen");} );109 google.maps.Event.addListener(map, "infowindowclose", function() { google.maps.Log.write("infowindowclose");} );110 }111 112 } 112 113 … … 118 119 !map.pwgDataHandler || map.pwgDataHandler.terminate(); 119 120 } 120 GUnload();121 121 } 122 122 … … 125 125 if (!q.length) return false; 126 126 if (!geocoder) 127 geocoder = new google.maps. ClientGeocoder();128 geocoder.ge tLocations(q, function(resp)129 {130 if ( resp && resp.Status)127 geocoder = new google.maps.Geocoder(); 128 geocoder.geocode(q, function(results, status) { 129 document._geoResponse = results; 130 if ( status == google.maps.GeocoderStatus.OK ) 131 131 { 132 document._geoResponse = resp; 133 if (resp.Status.code==200) 134 { 135 var zoom = 2; 136 switch (resp.Placemark[0].AddressDetails.Accuracy) 137 { 138 case 1: zoom=5; break; //country 139 case 2: zoom=7; break; //region 140 case 3: zoom=8; break; //county 141 case 4: zoom=12; break; //town 142 case 5: zoom=13; break; //post code 143 case 6: zoom=14; break; //street 144 case 7: case 8: zoom=16; break; //intersection/exact 145 } 146 map.setCenter( new google.maps.LatLng( resp.Placemark[0].Point.coordinates[1], resp.Placemark[0].Point.coordinates[0] ), zoom); 147 } 148 else 149 alert("This address has not been found\nCode:"+resp.Status.code); 150 } 151 }); 132 map.fitBounds( results[0].geometry.viewport ); 133 } 134 else 135 alert("This address has not been found\nCode: "+status); 136 }); 152 137 return false; 153 138 } -
extensions/rv_gmaps/trunk/template/page_linker.js
r6651 r12698 4 4 this._elementId = aElementId; 5 5 6 PageLinker.url2Map( map ); 7 8 google.maps.Event.bind( this._map, "maptypechanged", this, this._regenerateUrl ); 9 google.maps.Event.bind( this._map, "moveend", this, this._regenerateUrl ); 10 if ( this._map.isLoaded() ) 11 this._regenerateUrl(); 6 google.maps.event.bind( this._map, "idle", this, this._regenerateUrl ); 7 google.maps.event.bind( this._map, "maptypeid_changed", this, this._regenerateUrl ); 12 8 } 13 9 … … 32 28 vars['ll'] = map.getCenter().toUrlValue(5); 33 29 vars['z'] = map.getZoom(); 34 if ( map.get CurrentMapType()===G_NORMAL_MAP )30 if ( map.getMapTypeId()===google.maps.MapTypeId.ROADMAP ) 35 31 { if (vars['t']) vars['t']=null; } 36 32 else 37 vars['t']=map.get CurrentMapType().getUrlArg();33 vars['t']=map.getMapTypeId(); 38 34 39 35 var url = document.location.protocol+'//'+document.location.hostname+document.location.pathname; … … 50 46 }; 51 47 52 PageLinker.url2Map = function( map )48 PageLinker.url2Map = function( mapOptions ) 53 49 { 54 50 var vars = PageLinker.getQueryVars(); 55 51 if ( !( (vars['z'] && vars['ll']) || vars['t'] ) ) 56 return ;52 return false; 57 53 58 var mapType = G_NORMAL_MAP;54 var mapType = google.maps.MapTypeId.ROADMAP; 59 55 if (vars['t']) 60 56 for (var i=0; i<map.getMapTypes().length; i++) 61 57 if ( map.getMapTypes()[i].getUrlArg()==vars['t'] ) 62 58 { 63 map Type= map.getMapTypes()[i];break;59 mapOptions.mapTypeId = map.getMapTypes()[i];break; 64 60 } 65 61 66 62 if (vars['z'] && vars['ll']) 67 63 { 68 varzoom = parseFloat(vars['z']);64 mapOptions.zoom = parseFloat(vars['z']); 69 65 var ll = vars['ll'].split( "," ); 70 66 if (ll.length==2) 71 67 { 72 var center = new google.maps.LatLng( ll[0], ll[1] ); 73 map.setCenter( center, zoom, mapType ); 68 mapOptions.center = new google.maps.LatLng( ll[0], ll[1] ); 74 69 } 70 return true; 75 71 } 72 return false; 76 73 } 77 74
Note: See TracChangeset
for help on using the changeset viewer.