Changeset 12700 for extensions
- Timestamp:
- Dec 7, 2011, 5:39:56 AM (13 years ago)
- Location:
- extensions/rv_gmaps/trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/admin/admin.php
r3447 r12700 26 26 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); 27 27 28 if ( empty($conf['gmaps_api_key']) )29 $page['infos'][] = 'Please define the Google maps api key'; 28 /*if ( empty($conf['gmaps_api_key']) ) 29 $page['infos'][] = 'Please define the Google maps api key';*/ 30 30 31 31 ?> -
extensions/rv_gmaps/trunk/admin/admin_config.php
r8367 r12700 6 6 if ( isset($_POST['submit']) ) 7 7 { 8 $query = ' 8 if (isset($_POST['gmaps_api_key'])) 9 { 10 $query = ' 9 11 UPDATE '.CONFIG_TABLE.' 10 12 SET value="'.$_POST['gmaps_api_key'].'" 11 13 WHERE param="gmaps_api_key" 12 14 LIMIT 1'; 13 pwg_query($query); 14 list($conf['gmaps_api_key']) = array_from_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param="gmaps_api_key"', 'value'); 15 pwg_query($query); 16 list($conf['gmaps_api_key']) = array_from_query('SELECT value FROM '.CONFIG_TABLE.' WHERE param="gmaps_api_key"', 'value'); 17 } 15 18 19 if (isset($_POST['gmaps_auto_sync'])) 20 { 21 conf_update_param('gmaps_auto_sync', "1"); 22 $conf['gmaps_auto_sync']=1; 23 } 24 else 25 { 26 $query = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="gmaps_auto_sync"'; 27 pwg_query($query); 28 unset($conf['gmaps_auto_sync']); 29 } 30 16 31 $gm_config = rvm_get_config(); 17 32 … … 42 57 'NB_GEOTAGGED' => $nb_geotagged, 43 58 'GMAPS_API_KEY' => $conf['gmaps_api_key'], 59 'GMAPS_AUTO_SYNC' => isset($conf['gmaps_auto_sync']) ? 1:0, 44 60 'NB_MARKERS' => rvm_get_config_var('nb_markers',40), 45 61 'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20), -
extensions/rv_gmaps/trunk/admin/admin_config.tpl
r8471 r12700 4 4 <form method="post" action="" class="properties"> 5 5 <fieldset> 6 <legend>Map configuration</legend> 7 <ul> 8 9 <li> 10 <label> 11 Google Maps API Key: 12 <input type="text" size="48" name="gmaps_api_key" value="{$GMAPS_API_KEY}" /> 13 </label> 14 <br/>Signup for the key here: <a href="http://www.google.com/apis/maps/signup.html" target="_blank">http://www.google.com/apis/maps/signup.html</a>. 15 </li> 16 17 <br/> 18 6 <legend>Map configuration</legend> 7 <ul> 8 9 <!--<li> 10 <label> 11 Google Maps API Key: 12 <input type="text" size="48" name="gmaps_api_key" value="{$GMAPS_API_KEY}" /> 13 </label> 14 <br/>Signup for the key here: <a href="http://www.google.com/apis/maps/signup.html" target="_blank">http://www.google.com/apis/maps/signup.html</a>. 15 </li> 16 <br/> --> 17 18 <li> 19 <label> 20 Automatically sync from exif 21 <input type="checkbox" name="gmaps_auto_sync" {if $GMAPS_AUTO_SYNC}checked="checked"{/if} /> 22 </label> 23 <br/><small>When metadata is synchronized, tour manual set coordinates might be overriden.</small> 24 </li> 25 <br/> 26 19 27 <li> 20 28 <label> … … 24 32 <br/><small>The images will be "clustered" based on this number and the visible region on the map.</small> 25 33 </li> 26 34 27 35 <br/> 28 36 29 37 <li> 30 38 <label> -
extensions/rv_gmaps/trunk/include/functions.php
r3447 r12700 36 36 function rvm_make_map_picture_url($params) 37 37 { 38 global $conf;39 if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )40 return "";41 38 $map_url = make_picture_url($params); 42 39 return add_url_params($map_url, array('map'=>null) ); … … 45 42 function rvm_duplicate_map_picture_url() 46 43 { 47 global $conf;48 if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )49 return "";50 44 $map_url = duplicate_picture_url(); 51 45 return add_url_params($map_url, array('map'=>null) ); … … 55 49 { 56 50 global $conf, $rvm_dir; 57 if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )58 return "";59 51 $url = get_root_url().'map'; 60 52 if ($conf['php_extension_in_urls']) -
extensions/rv_gmaps/trunk/main.inc.php
r12367 r12700 106 106 global $rvm_dir; 107 107 $map_url = rvm_duplicate_map_picture_url(); 108 if (!empty($map_url)) 109 { 110 $link_title = sprintf( l10n('displays %s on a map'), strip_tags($pictures['current']['name']) ); 111 $template->concat( 'PLUGIN_PICTURE_ACTIONS' , sprintf(RVM_ACTION_MODEL, 108 $link_title = sprintf( l10n('displays %s on a map'), strip_tags($pictures['current']['name']) ); 109 $template->concat( 'PLUGIN_PICTURE_ACTIONS' , sprintf(RVM_ACTION_MODEL, 112 110 $map_url, $link_title, ' target="_top"', 'map', 'map' 113 111 )); 114 }115 112 } 116 113 } -
extensions/rv_gmaps/trunk/template/data_handler.js
r12698 r12700 11 11 , opts || {} ); 12 12 13 google.maps.event.addListener( map, "infowindowclose", function() {map.getInfoWindow().pwgMarker=null;} ); 13 google.maps.event.bind( this._map, "click", this, this._onMapClick); 14 google.maps.event.bind( this._infoWindow, "domready", this, this._onInfoWindowDomReady); 14 15 } 15 16 … … 21 22 _markers: [], 22 23 _navHtmlIds: ["gotoPrevImage", "gotoNextImage"], 23 _timerBindPictureNavigation: null, 24 _navHtmlHandles: [], 25 _recursionProtect: 0, 24 26 _prevResult: { nb_items:0 }, 25 27 … … 69 71 { 70 72 var newMarkers = []; 71 var infoWindowMarker = this._infoWindow. pwgMarker;73 var infoWindowMarker = this._infoWindow.getAnchor(); 72 74 73 75 for (i=0; i<data.image_clusters.length; i++) … … 84 86 if (marker && marker==infoWindowMarker) 85 87 { 86 marker.setMap(null); 87 google.maps.event.clearListeners(marker, "click" ); 88 google.maps.event.clearListeners(marker, "dblclick" ); 89 this._infoWindow.pwgMarker = infoWindowMarker = null; 88 marker.setMap(null); 89 google.maps.event.clearInstanceListeners(marker); 90 90 if (document.is_debug) glog('removed marker with infoWindow'); 91 91 marker = this._markers.pop(); … … 95 95 { 96 96 marker = new google.maps.Marker(this.options.markerOptions); 97 98 97 marker.setPosition(cluster.position); 98 marker.setTitle(theTitle); 99 99 google.maps.event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) ); 100 100 google.maps.event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) ); 101 marker.setMap(this._map);102 101 } 103 102 else … … 106 105 marker.setPosition( cluster.position ); 107 106 marker.setTitle(theTitle); 108 marker.setMap(this._map);109 107 } 108 marker.setMap(this._map); 110 109 111 110 newMarkers.push(marker); … … 122 121 { 123 122 this._markers[i].setMap(null); 124 google.maps.event.clearListeners(this._markers[i], "click" ); 125 google.maps.event.clearListeners(this._markers[i], "dblclick" ); 123 google.maps.event.clearInstanceListeners(this._markers[i]); 126 124 } 127 125 128 126 this._markers = newMarkers; 129 130 127 this._prevResult.nb_items=data.nb_items; 131 128 } … … 136 133 _onMarkerClick: function( marker ) 137 134 { 138 if (this._infoWindow. pwgMarker== marker )135 if (this._infoWindow.getAnchor() == marker ) 139 136 return; // already open 140 137 var content = ""; … … 160 157 content += '<div id="pwgImageDetail">' + this.buildCurrentPictureHtml( marker ) + '</div>'; 161 158 159 var h; 160 while (h = this._navHtmlHandles.pop()) 161 google.maps.event.removeListener(h); 162 162 163 this._infoWindow.setContent( content ); 163 164 this._infoWindow.setPosition( marker.getPosition() ); 164 this._infoWindow.open( this._map ); 165 166 // bind to next / prev a little later because sometimes the nodes are not immediately created 167 if (this._timerBindPictureNavigation) clearTimeout(this._timerBindPictureNavigation); 168 this._timerBindPictureNavigation = null; 169 if (marker.pwg.images.length>1) 170 this._timerBindPictureNavigation = setTimeout( pwgBind(this, this._onTimeoutBindPictureNavigation, marker), 250 ); 165 this._infoWindow.open( this._map, marker ); 171 166 }, 172 167 … … 174 169 { 175 170 this._map.fitBounds( marker.pwg.bounds ); 171 }, 172 173 _onMapClick: function( marker ) 174 { 175 this._infoWindow.close(); 176 176 }, 177 177 … … 204 204 205 205 206 _onTimeoutBindPictureNavigation: function( marker ) 207 { 208 clearTimeout(this._timerBindPictureNavigation); 209 this._timerBindPictureNavigation = null; 210 this._infoWindow.pwgMarker = marker; 211 for (var i=0; i< this._navHtmlIds.length; i++) 212 { 213 var elt = document.getElementById( this._navHtmlIds[i] ); 214 if (elt) 215 google.maps.event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, marker, i) ); 206 _onInfoWindowDomReady: function() 207 { 208 if (this._recursionProtect) 209 return; 210 if (!this._infoWindow.getAnchor() || this._infoWindow.getAnchor().pwg.images.length<2) 211 return; 212 try { 213 this._recursionProtect = 1; 214 for (var i=0; i< this._navHtmlIds.length; i++) 215 { 216 var elt = document.getElementById( this._navHtmlIds[i] ); 217 if (elt) 218 this._navHtmlHandles.push( google.maps.event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, this._infoWindow.getAnchor(), i) ) ); 219 } 220 } 221 finally { 222 this._recursionProtect = 0; 216 223 } 217 224 }, -
extensions/rv_gmaps/trunk/template/data_loader.js
r12698 r12700 4 4 this.options = jQuery.fn.extend( 5 5 { 6 reload_data_timeout: 500,6 reload_data_timeout: 200, 7 7 rectangle_of_confusion: new google.maps.Size(32,16) 8 8 } … … 92 92 if ( this._map.getZoom() <= this._previousLoadDataReq.zoom ) 93 93 return; 94 else95 {96 if (97 this._map.getZoom() == this._previousLoadDataReq.zoom + 198 && this._map.getZoom() < this._map.getBoundsZoomLevel(this._previousLoadDataReq.resultBounds)99 )100 {101 if (document.is_debug) google.maps.Log.write('no load: zoom crt: '+this._map.getZoom()+'; prev: '+this._previousLoadDataReq.zoom+'; target: '+this._map.getBoundsZoomLevel(this._previousLoadDataReq.resultBounds));102 return;103 }104 }105 }106 else107 {108 94 } 109 95 } -
extensions/rv_gmaps/trunk/template/map.tpl
r12698 r12700 59 59 var mapOptions = { 60 60 mapTypeId: google.maps.MapTypeId.ROADMAP, 61 overviewMapControl: true 62 } 63 64 if (1/*!PageLinker.url2Map(mapOptions)*/) 61 overviewMapControl: true, 62 overviewMapControlOptions: {opened: true} 63 } 64 65 if (!PageLinker.url2Map(mapOptions)) 65 66 { 66 67 {/literal} … … 106 107 ); 107 108 108 map.pwgDataHandler = new PwgDataHandler(map, { icon: pwgMarkerOptions, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );109 map.pwgDataHandler = new PwgDataHandler(map, {markerOptions: pwgMarkerOptions, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } ); 109 110 google.maps.event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) ); 110 111 -
extensions/rv_gmaps/trunk/template/markers/small_bullet_orange.tpl
r6609 r12700 1 var icon = new google.maps.Icon(); 2 icon.image = "{$PLUGIN_ROOT_URL}/template/markers/small_bullet_orange.png"; 3 icon.iconSize = new google.maps.Size(11, 11); 4 icon.iconAnchor = new google.maps.Point(5, 5); 5 icon.infoWindowAnchor = new google.maps.Point(5, 0); 6 return icon; 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(11, 11), 3 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/small_bullet_orange.png", 4 new google.maps.Size(11, 11), 5 new google.maps.Point(0, 0), 6 new google.maps.Point(5, 0)) 7 } -
extensions/rv_gmaps/trunk/template/markers/small_bullet_red.tpl
r6609 r12700 1 var icon = new google.maps.Icon(); 2 icon.image = "{$PLUGIN_ROOT_URL}/template/markers/small_bullet_red.png"; 3 icon.iconSize = new google.maps.Size(11, 11); 4 icon.iconAnchor = new google.maps.Point(5, 5); 5 icon.infoWindowAnchor = new google.maps.Point(5, 0); 6 return icon; 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(11, 11), 3 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/small_bullet_red.png", 4 new google.maps.Size(11, 11), 5 new google.maps.Point(0, 0), 6 new google.maps.Point(5, 5)) 7 } -
extensions/rv_gmaps/trunk/template/markers/small_bullet_yellow.tpl
r6609 r12700 1 var icon = new google.maps.Icon(); 2 icon.image = "{$PLUGIN_ROOT_URL}/template/markers/small_bullet_yellow.png"; 3 icon.iconSize = new google.maps.Size(11, 11); 4 icon.iconAnchor = new google.maps.Point(5, 5); 5 icon.infoWindowAnchor = new google.maps.Point(5, 0); 6 return icon; 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(11, 11), 3 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/small_bullet_yellow.png", 4 new google.maps.Size(11, 11), 5 new google.maps.Point(0, 0), 6 new google.maps.Point(5, 5)) 7 } -
extensions/rv_gmaps/trunk/template/page_linker.js
r12698 r12700 1 1 function PageLinker(map, aElementId) 2 2 { 3 4 3 this._map = map; 4 this._elementId = aElementId; 5 5 6 7 6 google.maps.event.bind( this._map, "idle", this, this._regenerateUrl ); 7 google.maps.event.bind( this._map, "maptypeid_changed", this, this._regenerateUrl ); 8 8 } 9 9 10 10 PageLinker.getQueryVars = function() 11 11 { 12 13 14 15 16 17 18 19 20 21 22 12 var vars = {}; 13 var qString = unescape( top.location.search.substring(1) ); 14 if (qString.length==0) 15 return vars; 16 var pairs = qString.split(/\&/); 17 for (var i=0; i<pairs.length; i++ ) 18 { 19 var nameVal = pairs[i].split(/\=/); 20 vars[nameVal[0]] = nameVal[1]; 21 } 22 return vars; 23 23 }; 24 24 25 25 PageLinker.map2Url = function( map ) 26 26 { 27 28 29 30 31 32 33 27 var vars = PageLinker.getQueryVars(); 28 vars['ll'] = map.getCenter().toUrlValue(5); 29 vars['z'] = map.getZoom(); 30 if ( map.getMapTypeId()===google.maps.MapTypeId.ROADMAP ) 31 { if (vars['t']) vars['t']=null; } 32 else 33 vars['t']=map.getMapTypeId(); 34 34 35 36 37 38 39 40 41 42 43 44 45 35 var url = document.location.protocol+'//'+document.location.hostname+document.location.pathname; 36 var bFirst = true; 37 for (var key in vars) 38 { 39 url += bFirst ? "?" : "&"; 40 bFirst = false; 41 url += key; 42 if (vars[key]!=null) 43 url += "="+vars[key]; 44 } 45 return url; 46 46 }; 47 47 48 48 PageLinker.url2Map = function( mapOptions ) 49 49 { 50 51 52 50 var vars = PageLinker.getQueryVars(); 51 if ( !( (vars['z'] && vars['ll']) || vars['t'] ) ) 52 return false; 53 53 54 var mapType = google.maps.MapTypeId.ROADMAP; 55 if (vars['t']) 56 for (var i=0; i<map.getMapTypes().length; i++) 57 if ( map.getMapTypes()[i].getUrlArg()==vars['t'] ) 58 { 59 mapOptions.mapTypeId = map.getMapTypes()[i];break; 60 } 61 62 if (vars['z'] && vars['ll']) 63 { 64 mapOptions.zoom = parseFloat(vars['z']); 65 var ll = vars['ll'].split( "," ); 66 if (ll.length==2) 67 { 68 mapOptions.center = new google.maps.LatLng( ll[0], ll[1] ); 69 } 70 return true; 71 } 72 return false; 54 var mapType = google.maps.MapTypeId.ROADMAP; 55 if (vars['t']) 56 mapOptions.mapTypeId = vars['t']; 57 58 if (vars['z'] && vars['ll']) 59 { 60 mapOptions.zoom = parseFloat(vars['z']); 61 var ll = vars['ll'].split( "," ); 62 if (ll.length==2) 63 { 64 mapOptions.center = new google.maps.LatLng( ll[0], ll[1] ); 65 } 66 return true; 67 } 68 return false; 73 69 } 74 70
Note: See TracChangeset
for help on using the changeset viewer.