Changeset 12719 for extensions
- Timestamp:
- Dec 11, 2011, 8:55:04 PM (12 years ago)
- Location:
- extensions/rv_gmaps/trunk
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/admin/admin_config.tpl
r12700 r12719 47 47 <li> 48 48 <label> 49 Marker image:49 Marker style: 50 50 <select name="marker_icon"> 51 51 <option value="">Default</option> -
extensions/rv_gmaps/trunk/changelog.txt
r12706 r12719 3 3 - fix some bad markers not showing (google removed some images from their servers) 4 4 - added some new marker icons 5 - markers can have different shape depending on the number of pictures 5 6 - full migration to maps api v3 6 7 -
extensions/rv_gmaps/trunk/include/cluster_maker.php
r3447 r12719 3 3 function cluster_area_compare( &$a, &$b ) 4 4 { 5 $aa = bounds_lat_range($a ['bounds']) * bounds_lon_range($a['bounds']);6 $ab = bounds_lat_range($b ['bounds']) * bounds_lon_range($b['bounds']);5 $aa = bounds_lat_range($a->bounds) * bounds_lon_range($a->bounds); 6 $ab = bounds_lat_range($b->bounds) * bounds_lon_range($b->bounds); 7 7 return -$aa+$ab; // biggest first 8 } 9 10 final class Cluster 11 { 12 public $bounds; 13 public $items; 14 15 function __construct($b = array(), $i = array()) 16 { 17 $this->bounds = $b; 18 $this->items = $i; 19 } 8 20 } 9 21 … … 30 42 $this->bounds = bounds_add($this->bounds, $img['lat'], $img['lon'] ); 31 43 32 $pending_split = array( 33 array( 34 'bounds' => $this->bounds, 35 'items' => array_keys( $this->_image_map ), 36 ) 37 ); 44 $pending_split = array( new Cluster($this->bounds, array_keys($this->_image_map) ) ); 38 45 $result = array(); 39 46 … … 51 58 foreach( $splitted as $k => $split ) 52 59 echo("sub $k: " . var_export($split['bounds'],true)."\n" );*/ 53 $total_iterations += count($current ['items']);60 $total_iterations += count($current->items); 54 61 $next_level_to_split = array_merge($next_level_to_split, $splitted ); 55 62 if ( count($result)+count($pending_split)+count($next_level_to_split) >= $maxNbMarkers ) … … 66 73 usort( $pending_split, 'cluster_area_compare' ); 67 74 } 75 68 76 $merged = $this->_try_merge_clusters( $result, $maxLatPrecision, $maxLonPrecision ); 69 77 $this->debug_str = get_elapsed_time($start, get_moment()) .' gen:'.$total_generations.' alg:'.count($this->_image_map).'+'.$total_iterations; … … 79 87 for ($i=0; $i<count($clusters)-1; $i++) 80 88 { 81 $ci = bounds_center( $clusters[$i] ['bounds']);89 $ci = bounds_center( $clusters[$i]->bounds ); 82 90 for ($j=$i+1; $j<count($clusters); $j++) 83 91 { 84 $cj = bounds_center( $clusters[$j]['bounds'] ); 85 if ( abs($ci['lat']-$cj['lat']) < $maxLatPrecision/2 86 and abs($ci['lon']-$cj['lon']) < $maxLonPrecision/2 ) 92 $cj = bounds_center( $clusters[$j]->bounds ); 93 $rlat = abs($ci['lat']-$cj['lat']) / $maxLatPrecision; 94 $rlon = abs($ci['lon']-$cj['lon']) / $maxLonPrecision; 95 if ( $rlat<1 && $rlon<1 96 && $rlat+$rlon<1.1) 87 97 { 88 98 //print_r( "i=$i; j=$j \n"); var_export( $clusters[$i]['bounds'] ); var_export( $clusters[$j]['bounds'] ); 89 $clusters[$i] ['items'] = array_merge( $clusters[$i]['items'], $clusters[$j]['items']);99 $clusters[$i]->items = array_merge( $clusters[$i]->items, $clusters[$j]->items ); 90 100 if ( empty($this->_image_ranks) ) 91 101 $this->_image_ranks = array_flip( array_keys($this->_image_map) ); 92 usort( $clusters[$i] ['items'], array($this, '_image_rank_compare') );93 $clusters[$i] ['bounds'] = bounds_union($clusters[$i]['bounds'], $clusters[$j]['bounds']);102 usort( $clusters[$i]->items, array($this, '_image_rank_compare') ); 103 $clusters[$i]->bounds = bounds_union($clusters[$i]->bounds, $clusters[$j]->bounds ); 94 104 array_splice( $clusters, $j, 1); 95 105 $j--; 96 $ci = bounds_center( $clusters[$i] ['bounds']);106 $ci = bounds_center( $clusters[$i]->bounds ); 97 107 $ret++; 98 108 } … … 109 119 function _split_cluster($cluster, $maxLatPrecision, $maxLonPrecision) 110 120 { 111 $latRange = bounds_lat_range($cluster ['bounds']);112 $lonRange = bounds_lon_range($cluster ['bounds']);121 $latRange = bounds_lat_range($cluster->bounds); 122 $lonRange = bounds_lon_range($cluster->bounds); 113 123 114 124 $lat_nb_tiles = max( 1, $latRange/$maxLatPrecision ); … … 146 156 } 147 157 148 if ( $cluster ['bounds']['count'] > 200 )158 if ( $cluster->bounds['count'] > 200 ) 149 159 { 150 160 if ($lat_step>4*$maxLatPrecision) $lat_step = $lat_step/2; … … 159 169 160 170 $clusters = array(); 161 foreach ( $cluster ['items']as $id )171 foreach ( $cluster->items as $id ) 162 172 { 163 173 $lon = $this->_image_map[$id]['lon']; 164 174 $lat = $this->_image_map[$id]['lat']; 165 175 166 $idx_lon = floor ( ( $lon - $cluster ['bounds']['w'] ) / $lon_step );167 $idx_lat = floor ( ( $lat - $cluster ['bounds']['s'] ) / $lat_step );176 $idx_lon = floor ( ( $lon - $cluster->bounds['w'] ) / $lon_step ); 177 $idx_lat = floor ( ( $lat - $cluster->bounds['s'] ) / $lat_step ); 168 178 169 179 $idx = $lon_nb_tiles * $idx_lat + $idx_lon; … … 171 181 if ( !isset($clusters[$idx]) ) 172 182 { 173 $clusters[$idx] = array( 174 'bounds' => array(), 175 'items' => array(), 176 ); 183 $clusters[$idx] = new Cluster(); 177 184 } 178 array_push( $clusters[$idx] ['items'], $id );179 $clusters[$idx] ['bounds'] = bounds_add( $clusters[$idx]['bounds'], $lat, $lon );185 array_push( $clusters[$idx]->items, $id ); 186 $clusters[$idx]->bounds = bounds_add( $clusters[$idx]->bounds , $lat, $lon ); 180 187 } 181 188 return $clusters; -
extensions/rv_gmaps/trunk/map.php
r12698 r12719 84 84 } 85 85 else 86 $template->assign('MAP_MARKER_ICON_JS', ' return {}');86 $template->assign('MAP_MARKER_ICON_JS', 'new PwgSingleStyler()'); 87 87 88 88 $template->pparse('map'); -
extensions/rv_gmaps/trunk/map_data.php
r12706 r12719 122 122 if ($i) rvo( ",\n\n" ); 123 123 rvo( "{" ); 124 rvo( 'position: '. jsgm_position( bounds_center($c ['bounds']) ) );124 rvo( 'position: '. jsgm_position( bounds_center($c->bounds) ) ); 125 125 rvo( ",\n" ); 126 rvo( 'bounds: '. jsgm_bounds( $c ['bounds']) );126 rvo( 'bounds: '. jsgm_bounds( $c->bounds ) ); 127 127 rvo( ",\n" ); 128 rvo( 'nb_items: '.count($c ['items']) );128 rvo( 'nb_items: '.count($c->items) ); 129 129 rvo( ",\n" ); 130 130 131 rvo( 'blowup_url: "'.rvm_duplicate_blowup_url(array('box'=>$c ['bounds']), array('start') ). '"' );131 rvo( 'blowup_url: "'.rvm_duplicate_blowup_url(array('box'=>$c->bounds), array('start') ). '"' ); 132 132 rvo( ",\n" ); 133 133 134 134 $max_per_cluster = rvm_get_config_var('nb_images_per_marker',20); 135 if ( count($c ['items']) > $max_per_cluster )135 if ( count($c->items) > $max_per_cluster ) 136 136 { 137 $c ['items'] = array_slice($c['items'], 0, $max_per_cluster);137 $c->items = array_slice($c->items, 0, $max_per_cluster); 138 138 } 139 139 rvo( 'items: [' ); 140 for ($j=0; $j<count($c ['items']); $j++)140 for ($j=0; $j<count($c->items); $j++) 141 141 { 142 $img = $page['items'] [ $c ['items'][$j] ];142 $img = $page['items'] [ $c->items[$j] ]; 143 143 $img['file'] = basename( $img['path'] ); 144 144 if (!empty( $img['name'] ) ) -
extensions/rv_gmaps/trunk/template/data_handler.js
r12706 r12719 4 4 this._map = map; 5 5 this._infoWindow = new google.maps.InfoWindow(); 6 this.styler = opts.styler; 6 7 this.options = jQuery.fn.extend( 7 8 { 8 markerOptions: {},9 9 show_all_img_src: null 10 10 } … … 68 68 if (changed) 69 69 { 70 // BEGIN NEW **************** 71 var markersToRemove=[], clustersToAdd=[], newMarkers=[]; 70 var markersToRemove=[], clustersToAdd=[], newMarkers=[], cluster, marker; 72 71 data.image_clusters.sort( function(a,b) { return PwgDataHandler.cmpll( a.position, b.position); } ); 73 72 for (i=0; i<data.image_clusters.length; i++) 74 73 { 75 varcluster = data.image_clusters[i];74 cluster = data.image_clusters[i]; 76 75 while(this._markers.length) 77 76 { 78 varmarker = this._markers[0];77 marker = this._markers[0]; 79 78 if (PwgDataHandler.cmpll(cluster.position, marker.getPosition()) == 0) 80 79 { 80 marker.setOptions(this.styler.changeStyle(cluster, marker.pwg)); 81 81 marker.pwg = { 82 82 nb_items: cluster.nb_items, … … 111 111 for (i=0; i<clustersToAdd.length; i++) 112 112 { 113 var cluster = clustersToAdd[i]; 114 var theTitle = ""; 115 if (cluster.nb_items>1) 116 theTitle = Localization.fmt1("%d photos", cluster.nb_items); 117 else 118 theTitle = cluster.items[0].name; 119 120 var marker = markersToRemove.pop(); 113 cluster = clustersToAdd[i]; 114 115 var theTitle = (cluster.nb_items>1) ? Localization.fmt1("%d photos", cluster.nb_items) : cluster.items[0].name; 116 marker = markersToRemove.pop(); 121 117 if (marker && marker==infoWindowMarker) 122 118 { … … 129 125 if (!marker) 130 126 { 131 marker = new google.maps.Marker(this. options.markerOptions);127 marker = new google.maps.Marker(this.styler.getStyle(cluster)); 132 128 marker.setPosition(cluster.position); 133 129 marker.setTitle(theTitle); … … 141 137 marker.setPosition( cluster.position ); 142 138 marker.setTitle(theTitle); 139 marker.setOptions(this.styler.changeStyle(cluster, marker.pwg)); 143 140 } 144 141 … … 161 158 this._markers = newMarkers; 162 159 this._markers.sort( function(a,b) { return PwgDataHandler.cmpll( a.getPosition(), b.getPosition()); } ); 163 // END new164 165 /* var newMarkers = [];166 var infoWindowMarker = this._infoWindow.getAnchor();167 168 for (i=0; i<data.image_clusters.length; i++)169 {170 var cluster = data.image_clusters[i];171 var theTitle = "";172 if (cluster.nb_items>1)173 theTitle = Localization.fmt1("%d photos", cluster.nb_items);174 else175 theTitle = cluster.items[0].name;176 177 var marker;178 marker = this._markers.pop();179 if (marker && marker==infoWindowMarker)180 {181 marker.setMap(null);182 google.maps.event.clearInstanceListeners(marker);183 if (document.is_debug) glog('removed marker with infoWindow');184 marker = this._markers.pop();185 }186 187 if (!marker)188 {189 marker = new google.maps.Marker(this.options.markerOptions);190 marker.setPosition(cluster.position);191 marker.setTitle(theTitle);192 google.maps.event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) );193 google.maps.event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) );194 }195 else196 {197 marker.currentImageIndex=0;198 marker.setPosition( cluster.position );199 marker.setTitle(theTitle);200 }201 marker.setMap(this._map);202 203 newMarkers.push(marker);204 205 marker.pwg = {206 nb_items: cluster.nb_items,207 images: cluster.items,208 bounds: cluster.bounds,209 blowup_url: cluster.blowup_url210 };211 }212 213 for (i=0; i<this._markers.length; i++)214 {215 this._markers[i].setMap(null);216 google.maps.event.clearInstanceListeners(this._markers[i]);217 }218 */219 this._markers = newMarkers;220 160 this._prevResult.nb_items=data.nb_items; 221 161 } -
extensions/rv_gmaps/trunk/template/data_loader.js
r12706 r12719 37 37 { 38 38 this._urlMapData = urlMapData; 39 google.maps.event.bind( this._map, " movestart", this, this.clearTimerReloadData );39 google.maps.event.bind( this._map, "dragstart", this, this.clearTimerReloadData ); 40 40 google.maps.event.bind( this._map, "idle", this, this._onIdle ); 41 41 //this._loadData(); … … 102 102 103 103 if (isOver) 104 bounds = new google.maps.LatLngBounds( new google.maps.LatLng(this._map.getBounds().getSouthWest().lat(),-1 79.9), new google.maps.LatLng(this._map.getBounds().getNorthEast().lat(), 179.9) );104 bounds = new google.maps.LatLngBounds( new google.maps.LatLng(this._map.getBounds().getSouthWest().lat(),-180), new google.maps.LatLng(this._map.getBounds().getNorthEast().lat(), 179.99) ); 105 105 //END bug 106 106 … … 184 184 catch (e) { 185 185 this._previousLoadDataReq.box=null; 186 google.maps.event.trigger( this, "dataloadfailed", responseCode, e );186 google.maps.event.trigger( this, "dataloadfailed", textStatus, e ); 187 187 var s = e.message; 188 188 s += '\n' + data.substr(0,1000); -
extensions/rv_gmaps/trunk/template/map.tpl
r12706 r12719 17 17 {combine_script id='rvm.dh' load='header' path="`$PLUGIN_LOCATION`/template/data_handler.js" version=$RVM_PLUGIN_VERSION} 18 18 {combine_script id='rvm.pl' load='header' path="`$PLUGIN_LOCATION`/template/page_linker.js" version=$RVM_PLUGIN_VERSION} 19 {combine_script id='rvm.st' load='header' path="`$PLUGIN_LOCATION`/template/styler.js" version=$RVM_PLUGIN_VERSION} 19 20 {combine_script id='core.scripts' load='header' path='themes/default/js/scripts.js'} 20 21 … … 40 41 //<![CDATA[ 41 42 var map; 42 var geocoder;43 43 44 44 document.is_debug = false; 45 45 if ( document.location.search.match(/[\?&]debug/) ) { 46 46 document.is_debug = true; 47 document._window = window;48 47 } 49 48 … … 97 96 pwgPageLinker = new PageLinker(map, "aLinkToThisPage" ); 98 97 99 var pwgMarkerOptions = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null); 100 101 map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerOptions.roc} ); 98 /*var pwgMarkerOptions = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null);*/ 99 var pwgStyler = {/literal}{$MAP_MARKER_ICON_JS}{literal}; 100 101 map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgStyler.roc} ); 102 102 google.maps.event.addListener(map.pwgDataLoader, "dataloading", function() { 103 103 var pre = '<img src="{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/progress_s.gif" width="16" height="16" alt="~" /> '; … … 111 111 ); 112 112 113 map.pwgDataHandler = new PwgDataHandler(map, { markerOptions: pwgMarkerOptions, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );113 map.pwgDataHandler = new PwgDataHandler(map, {styler: pwgStyler, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } ); 114 114 google.maps.event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) ); 115 115 … … 136 136 !map.pwgDataHandler || map.pwgDataHandler.terminate(); 137 137 } 138 }139 140 function searchLocation(q)141 {142 if (!q.length) return false;143 if (!geocoder)144 geocoder = new google.maps.Geocoder();145 geocoder.geocode(q, function(results, status) {146 document._geoResponse = results;147 if ( status == google.maps.GeocoderStatus.OK )148 {149 map.fitBounds( results[0].geometry.viewport );150 }151 else152 alert("This address has not been found\nCode: "+status);153 });154 return false;155 138 } 156 139 -
extensions/rv_gmaps/trunk/template/markers/medium_gradient_blue.tpl
r12706 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(12, 20), 1 new PwgSingleStyler( {ldelim} 3 2 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/medium_gradient_blue.png", 4 3 new google.maps.Size(12, 20), //size … … 6 5 new google.maps.Point(6, 20) //anchor 7 6 ) 8 } 7 }, 8 new google.maps.Size(12, 20) ) 9 -
extensions/rv_gmaps/trunk/template/markers/medium_gradient_purple.tpl
r12706 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(12, 20), 1 new PwgSingleStyler( {ldelim} 3 2 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/medium_gradient_purple.png", 4 3 new google.maps.Size(12, 20), //size … … 6 5 new google.maps.Point(6, 20) //anchor 7 6 ) 8 } 7 }, 8 new google.maps.Size(12, 20) ) 9 -
extensions/rv_gmaps/trunk/template/markers/medium_gradient_red.tpl
r12706 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(12, 20), 1 new PwgSingleStyler( {ldelim} 3 2 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/medium_gradient_red.png", 4 3 new google.maps.Size(12, 20), //size … … 6 5 new google.maps.Point(6, 20) //anchor 7 6 ) 8 } 7 }, 8 new google.maps.Size(12, 20) ) 9 -
extensions/rv_gmaps/trunk/template/markers/medium_standard_red.tpl
r12706 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(12, 20), 1 new PwgSingleStyler( {ldelim} 3 2 icon: new google.maps.MarkerImage("{$PLUGIN_ROOT_URL}/template/markers/medium_standard_red.png", 4 3 new google.maps.Size(12, 20), //size 5 4 new google.maps.Point(0, 0), //origin 6 5 new google.maps.Point(6, 20) //anchor 7 ) /*,8 shadow: "{$PLUGIN_ROOT_URL}/template/markers/medium_standard_shadow.png"*/9 } 6 ) 7 }, 8 new google.maps.Size(12, 20) ) -
extensions/rv_gmaps/trunk/template/markers/small_bullet_orange.tpl
r12700 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(11, 11), 1 new PwgSingleStyler( {ldelim} 3 2 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 } 3 new google.maps.Size(11, 11), //size 4 new google.maps.Point(0, 0), //origin 5 new google.maps.Point(5, 0) //anchor 6 ) 7 }, 8 new google.maps.Size(11, 11) ) -
extensions/rv_gmaps/trunk/template/markers/small_bullet_red.tpl
r12700 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(11, 11), 1 new PwgSingleStyler( {ldelim} 3 2 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 } 3 new google.maps.Size(11, 11), //size 4 new google.maps.Point(0, 0), //origin 5 new google.maps.Point(5, 0) //anchor 6 ) 7 }, 8 new google.maps.Size(11, 11) ) -
extensions/rv_gmaps/trunk/template/markers/small_bullet_yellow.tpl
r12700 r12719 1 return {ldelim} 2 rectangle_of_precision: new google.maps.Size(11, 11), 1 new PwgSingleStyler( {ldelim} 3 2 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 } 3 new google.maps.Size(11, 11), //size 4 new google.maps.Point(0, 0), //origin 5 new google.maps.Point(5, 0) //anchor 6 ) 7 }, 8 new google.maps.Size(11, 11) ) -
extensions/rv_gmaps/trunk/template/picture_map_content.tpl
r12706 r12719 1 1 2 2 {html_head} 3 <script src="http://maps.google <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language={$lang_info.code}" type="text/javascript"></script>3 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language={$lang_info.code}" type="text/javascript"></script> 4 4 {combine_script id='jquery' load='header' path='themes/default/js/jquery.min.js'} 5 5 {combine_script id='jquery.nyroModal' load='async' path="`$PLUGIN_LOCATION`/template/nyroModal/jquery.nyroModal-1.6.2.js" version='1.6.2'}
Note: See TracChangeset
for help on using the changeset viewer.