Changeset 5018 for extensions
- Timestamp:
- Mar 1, 2010, 10:29:55 PM (15 years ago)
- Location:
- extensions/rv_gmaps/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/changelog.txt
r4070 r5018 1 2.0.d 2 - hungarian translation thanks to external contributors 3 - the map uses now the 3D Large map control as on google maps website 4 - dirty fix for bug inroduced in api version 2.185 (and up to 2.193 as of now online) - http://code.google.com/p/gmaps-api-issues/issues/detail?id=2009&q=apitype%3AJavascript&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars 5 1 6 2.0.c 2 7 - google maps api is loaded using the same language as piwigo -
extensions/rv_gmaps/trunk/main.inc.php
r4070 r5018 1 1 <?php /* 2 2 Plugin Name: RV Maps&Earth 3 Version: 2.0. c3 Version: 2.0.d 4 4 Description: Extend your gallery with Google Maps and Google Earth ... 5 5 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=122 … … 7 7 Author URI: http://www.modusoptimus.com/ 8 8 */ 9 define( 'RVM_PLUGIN_VERSION', '2.0. c');9 define( 'RVM_PLUGIN_VERSION', '2.0.d'); 10 10 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 11 11 -
extensions/rv_gmaps/trunk/template/data_loader.js
r3447 r5018 1 1 function PwgDataLoader( map, opts ) 2 2 { 3 4 5 6 7 8 9 10 11 12 3 this._map = map; 4 this.options = Object.extend( 5 { 6 reload_data_timeout: 1800, 7 rectangle_of_confusion: G_DEFAULT_ICON.iconSize 8 } 9 , opts || {} ); 10 this.options.rectangle_of_confusion = new GSize( this.options.rectangle_of_confusion.width, this.options.rectangle_of_confusion.height ); 11 if (this.options.rectangle_of_confusion.width<16) this.options.rectangle_of_confusion.width=16; 12 if (this.options.rectangle_of_confusion.height<16) this.options.rectangle_of_confusion.height=16; 13 13 } 14 14 … … 17 17 getLatLonDigits = function(d, factor, exp) 18 18 { 19 20 21 19 if (d<0) return getLatLonDigits(-d,factor,exp); 20 var digits = Math.ceil( exp - Math.log(d*factor)/Math.LN10 ); 21 return digits<0 ? 0 : (digits>6 ? 6 : digits); 22 22 } 23 23 … … 36 36 start: function(urlMapData) 37 37 { 38 39 40 41 38 this._urlMapData = urlMapData; 39 GEvent.bind( this._map, "movestart", this, this.clearTimerReloadData ); 40 GEvent.bind( this._map, "moveend", this, this._onMapMoveEnd ); 41 this._loadData(); 42 42 }, 43 43 44 44 terminate: function() 45 45 { 46 47 46 this.clearTimerReloadData(); 47 this._map = null; 48 48 }, 49 49 50 50 clearTimerReloadData : function() 51 51 { 52 53 54 55 56 57 58 52 if (this._timerReloadData) 53 { 54 clearTimeout( this._timerReloadData ); 55 this._timerReloadData = null; 56 return true; 57 } 58 return false; 59 59 }, 60 60 61 61 _onMapMoveEnd: function() 62 62 { 63 this.clearTimerReloadData(); 64 this._timerReloadData = setTimeout( 65 this._onTimeoutLoadData.bind(this), 66 this.options.reload_data_timeout); 63 this.clearTimerReloadData(); 64 this._timerReloadData = setTimeout( this._onTimeoutLoadData.bind(this), this.options.reload_data_timeout ); 67 65 }, 68 66 … … 70 68 _onTimeoutLoadData: function () 71 69 { 72 73 74 70 if (this._dataLoading) return; // still in progress 71 this.clearTimerReloadData(); 72 this._loadData(); 75 73 }, 76 74 77 75 _loadData: function() 78 76 { 79 77 var bounds = this._map.getBounds(); 80 78 81 var latRange = bounds.toSpan().lat(); 82 var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getSize().height; 79 // BEGIN BUG in maps api 2.185 up to "today" 2.193 - when map wraps horizontally more than 360 deg - the getBounds is wrong 80 if ( this._map.getZoom() <= 2 ) 81 { 82 bounds = new GLatLngBounds( 83 new GLatLng( bounds.getSouthWest().lat(), -180 ), 84 new GLatLng( bounds.getNorthEast().lat(), 180 ) 85 ); 86 } 87 // END BUG 88 var latRange = bounds.toSpan().lat(); 89 var latPrec = latRange * this.options.rectangle_of_confusion.height / this._map.getSize().height; 83 90 84 85 91 var lonRange = bounds.toSpan().lng(); 92 var lonPrec = ( lonRange>=0 ? lonRange : 360-lonRange )* this.options.rectangle_of_confusion.width / this._map.getSize().width; 86 93 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 94 if ( this._previousLoadDataReq.box!=null ) 95 { // not the first time 96 if ( this._previousLoadDataReq.box.containsBounds( bounds ) ) 97 { 98 if ( this._previousLoadDataReq.resultBounds == null ) 99 return; // no images here 100 if ( this._map.getZoom() <= this._previousLoadDataReq.zoom ) 101 return; 102 else 103 { 104 if ( 105 this._map.getZoom() == this._previousLoadDataReq.zoom + 1 106 && this._map.getZoom() < this._map.getBoundsZoomLevel(this._previousLoadDataReq.resultBounds) 107 ) 108 { 109 if (document.is_debug) GLog.write('no load: zoom crt: '+this._map.getZoom()+'; prev: '+this._previousLoadDataReq.zoom+'; target: '+this._map.getBoundsZoomLevel(this._previousLoadDataReq.resultBounds)); 110 return; 111 } 112 } 113 } 114 else 115 { 116 } 117 } 111 118 112 var nd=0, sd=0, ed=0, wd=0; 113 if ( !bounds.isFullLat() ) 114 { 115 nd = latRange*12/100; 116 sd = latRange*4/100; 117 } 118 if ( !bounds.isFullLng() ) 119 { 120 ed = lonRange*9/100; 121 wd = lonRange*7/100; 122 } 123 var digits = Math.max( getLatLonDigits(latRange,4,2), getLatLonDigits(lonRange,4,2) ); 124 var box = new GLatLngBounds( 125 new GLatLng( Math.roundN(bounds.getSouthWest().lat()-sd,digits), Math.roundN( bounds.getSouthWest().lng()-wd,digits ) ), 126 new GLatLng( Math.roundN(bounds.getNorthEast().lat()+nd,digits), Math.roundN(bounds.getNorthEast().lng()+ed,digits) ) 127 ); 128 129 var url = this._urlMapData; 130 url += "&box=" + box.getSouthWest().toUrlValue(5) + "," + box.getNorthEast().toUrlValue(5); 131 url += "&lap=" + Math.roundN( latPrec, getLatLonDigits(latPrec,1,1) ).toString(); 132 url += "&lop=" + Math.roundN( lonPrec, getLatLonDigits(lonPrec,1,1) ).toString(); 133 134 if (document.is_debug) { 135 GLog.write( "bounds: " + bounds.getSouthWest().toUrlValue() + " " + bounds.getNorthEast().toUrlValue() +"; zoom: "+this._map.getZoom() +"; size: "+this._map.getSize().toString() +"; c: "+this._map.getCenter().toUrlValue() ); 136 GLog.writeUrl( url ); 137 } 138 139 this._previousLoadDataReq.box = box; 140 this._previousLoadDataReq.zoom = this._map.getZoom(); 141 this._previousLoadDataReq.resultBounds = null; 142 this._dataLoading = true; 119 var nd=0, sd=0, ed=0, wd=0; 120 if ( !bounds.isFullLat() ) 121 { 122 nd = latRange*12/100; 123 sd = latRange*4/100; 124 } 125 if ( !bounds.isFullLng() ) 126 { 127 ed = lonRange*9/100; 128 wd = lonRange*7/100; 129 } 130 var digits = Math.max( getLatLonDigits(latRange,4,2), getLatLonDigits(lonRange,4,2) ); 131 var box = new GLatLngBounds( 132 new GLatLng( Math.roundN(bounds.getSouthWest().lat()-sd,digits), Math.roundN( bounds.getSouthWest().lng()-wd,digits ) ), 133 new GLatLng( Math.roundN(bounds.getNorthEast().lat()+nd,digits), Math.roundN( bounds.getNorthEast().lng()+ed,digits) ) 134 ); 143 135 144 try { 145 GEvent.trigger( this, "dataloading" ); 146 GDownloadUrl(url, this._onDataReceived.bind(this) ); 147 } 148 catch (e) { 149 this._dataLoading = false; 150 this._previousLoadDataReq.box=null; 151 GEvent.trigger( this, "dataloadfailed", 600, e ); 152 } 136 var url = this._urlMapData; 137 url += "&box=" + box.getSouthWest().toUrlValue(5) + "," + box.getNorthEast().toUrlValue(5); 138 url += "&lap=" + Math.roundN( latPrec, getLatLonDigits(latPrec,1,1) ).toString(); 139 url += "&lop=" + Math.roundN( lonPrec, getLatLonDigits(lonPrec,1,1) ).toString(); 140 141 if (document.is_debug) { 142 GLog.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() ); 143 GLog.writeUrl( url ); 144 } 145 146 this._previousLoadDataReq.box = box; 147 this._previousLoadDataReq.zoom = this._map.getZoom(); 148 this._previousLoadDataReq.resultBounds = null; 149 this._dataLoading = true; 150 151 try { 152 GEvent.trigger( this, "dataloading" ); 153 GDownloadUrl(url, this._onDataReceived.bind(this) ); 154 } 155 catch (e) { 156 this._dataLoading = false; 157 this._previousLoadDataReq.box=null; 158 GEvent.trigger( this, "dataloadfailed", 600, e ); 159 } 153 160 }, 154 161 155 162 _onDataReceived: function(data, responseCode) 156 163 { 157 158 159 160 161 162 163 164 165 166 167 168 169 170 164 var resp; 165 try 166 { 167 if (responseCode!=200) 168 { 169 this._previousLoadDataReq.box=null; 170 GEvent.trigger( this, "dataloadfailed", responseCode, null ); 171 } 172 else 173 try 174 { 175 eval('resp = ' + data); 176 if (resp.nb_items == undefined) 177 throw new Error( "DATA DECODING ERROR" ); 171 178 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 179 this._previousLoadDataReq.resultBounds = resp.bounds; 180 if (document.is_debug && resp.debug) GLog.write( resp.debug ); 181 GEvent.trigger( this, "dataloaded", resp ); 182 } 183 catch (e) { 184 this._previousLoadDataReq.box=null; 185 GEvent.trigger( this, "dataloadfailed", responseCode, e ); 186 var s = e.message; 187 s += '\n' + data.substr(0,1000); 188 alert( s ); 189 } 190 } 191 finally { 192 this._dataLoading = false; 193 } 187 194 } 188 195 -
extensions/rv_gmaps/trunk/template/map.tpl
r4070 r5018 35 35 document.is_debug = false; 36 36 if ( document.location.search.match(/[\?&]debug/) ) { 37 38 37 document.is_debug = true; 38 document._window = window; 39 39 } 40 40 … … 48 48 49 49 map.addMapType( G_PHYSICAL_MAP ); 50 map.addControl(new GLargeMapControl ());50 map.addControl(new GLargeMapControl3D()); 51 51 map.addControl(new GHierarchicalMapTypeControl()); 52 52 map.addControl(new GScaleControl()); … … 57 57 {/literal} 58 58 {if isset($initial_bounds)} 59 60 59 var bounds = new GLatLngBounds( new GLatLng({$initial_bounds.s},{$initial_bounds.w}), new GLatLng({$initial_bounds.n},{$initial_bounds.e}) ); 60 map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel( bounds ) ); 61 61 {/if} 62 62 {literal} 63 63 if ( !map.isLoaded() ) 64 64 map.setCenter( new GLatLng(0,0), 2 ); 65 66 67 65 } 66 67 try { 68 68 // the overview must be added after setting map center 69 69 var ovcontrol = new GOverviewMapControl(new GSize(165,165)); 70 70 map.addControl(ovcontrol); 71 72 73 71 } 72 catch(e){ alert( e.message ); } 73 74 74 map.enableScrollWheelZoom(); 75 75 map.enableDoubleClickZoom(); 76 76 77 77 var pwgMarkerIcon = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null); 78 78 … … 100 100 GEvent.addListener(map, "infowindowopen", function() { GLog.write("infowindowopen");} ); 101 101 GEvent.addListener(map, "infowindowclose", function() { GLog.write("infowindowclose");} ); 102 102 } 103 103 } 104 104 … … 120 120 geocoder.getLocations(q, function(resp) 121 121 { 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 122 if ( resp && resp.Status ) 123 { 124 document._geoResponse = resp; 125 if (resp.Status.code==200) 126 { 127 var zoom = 2; 128 switch (resp.Placemark[0].AddressDetails.Accuracy) 129 { 130 case 1: zoom=5; break; //country 131 case 2: zoom=7; break; //region 132 case 3: zoom=8; break; //county 133 case 4: zoom=12; break; //town 134 case 5: zoom=13; break; //post code 135 case 6: zoom=14; break; //street 136 case 7: case 8: zoom=16; break; //intersection/exact 137 } 138 map.setCenter( new GLatLng( resp.Placemark[0].Point.coordinates[1], resp.Placemark[0].Point.coordinates[0] ), zoom); 139 } 140 else 141 alert("This address has not been found\nCode:"+resp.Status.code); 142 } 143 143 }); 144 144 return false;
Note: See TracChangeset
for help on using the changeset viewer.