Changeset 12706


Ignore:
Timestamp:
Dec 8, 2011, 10:36:35 PM (12 years ago)
Author:
rvelices
Message:

rv_gmaps use places autocomplete + added new markers + better algo for displaying markers

Location:
extensions/rv_gmaps/trunk
Files:
8 added
3 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_gmaps/trunk/admin/admin_config.php

    r12701 r12706  
    6363  );
    6464
     65$files = array();
    6566$path=PHPWG_PLUGINS_PATH.$rvm_dir.'/template/markers/';
    6667$dir_contents = opendir($path);
     
    6970  if (!is_file($path.'/'.$filename) or get_extension($filename)!='tpl')
    7071    continue;
    71   $filename = get_filename_wo_extension( $filename );
    72   $template->append('marker_icons',
     72        $files[] = get_filename_wo_extension($filename);
     73 }
     74closedir($dir_contents);
     75
     76sort($files);
     77foreach($files as $file)
     78{
     79        $template->append('marker_icons',
    7380      array(
    74         $filename => str_replace( '_', ' ', $filename),
     81        $file => str_replace( '_', ' ', $file),
    7582      ),
    7683      true
     
    7986$template->assign('selected_marker_icon', rvm_get_config_var('marker_icon', '') );
    8087
    81 closedir($dir_contents);
     88
    8289?>
  • extensions/rv_gmaps/trunk/changelog.txt

    r12367 r12706  
     12.3.b
     2- search for places / location uses now google auto complete
     3- fix some bad markers not showing (google removed some images from their servers)
     4- added some new marker icons
     5- full migration to maps api v3
     6
    172.3.a
    28- fix jquery version
  • extensions/rv_gmaps/trunk/language/ar_SA/lang.php

    r8691 r12706  
    1313$lang['Show all']='اظهار الكل';
    1414$lang['show all pictures around this location']='اظهر كل الصور المحيطة بهذه';
    15 $lang['Search a location...']='البحث عن منطقة...';
    1615
    1716$lang['Loading']='تحميل';
  • extensions/rv_gmaps/trunk/language/cs_CZ/lang.php

    r8724 r12706  
    1313$lang['Show all']='Zobrazit vše';
    1414$lang['show all photos around this location']='zobrazit fotografie v okolí';
    15 $lang['Search a location...']='Najít polohu...';
    1615
    1716$lang['Loading']='Nahrávání';
  • extensions/rv_gmaps/trunk/language/de_DE/lang.php

    r8724 r12706  
    1313$lang['Show all']='Zeigt Alle';
    1414$lang['show all photos around this location']='zeigt alle Bilder rund um dieser Position';
    15 $lang['Search a location...']='Suche eine Position...';
    1615
    1716$lang['Loading']='lädt';
  • extensions/rv_gmaps/trunk/language/en_UK/lang.php

    r8724 r12706  
    1313$lang['Show all']='Show all';
    1414$lang['show all photos around this location']='show all photos around this location';
    15 $lang['Search a location...']='Search a location...';
    1615
    1716$lang['Loading']='Loading';
  • extensions/rv_gmaps/trunk/language/es_ES/lang.php

    r8724 r12706  
    1313$lang['Show all']='Presenta todo';
    1414$lang['show all photos around this location']='Presenta todas las imágenes cerca de estas coordenadas';
    15 $lang['Search a location...']='Buscar un lugar...';
    1615
    1716$lang['Loading']='Carga';
  • extensions/rv_gmaps/trunk/language/fr_FR/lang.php

    r8724 r12706  
    1313$lang['Show all']='Présente tout';
    1414$lang['show all photos around this location']='Présente toutes les images à proximité de ces coordonnées';
    15 $lang['Search a location...']='Rechercher un lieu...';
    1615
    1716$lang['Loading']='Chargement';
  • extensions/rv_gmaps/trunk/language/hu_HU/lang.php

    r8724 r12706  
    1313$lang['Show all']='Összes megjelenítése';
    1414$lang['show all photos around this location']='Összes kép mellé ezeket a koordinátákat';
    15 $lang['Search a location...']='Hely keresése...';
    1615
    1716$lang['Loading']='Töltés';
  • extensions/rv_gmaps/trunk/language/it_IT/lang.php

    r8724 r12706  
    1313$lang['Show all']='Presenta tutto';
    1414$lang['show all photos around this location']='Presenta tutte le immagini in prossimità di queste coordinate';
    15 $lang['Search a location...']='Cecare un luogo...';
    1615
    1716$lang['Loading']='Caricamento';
  • extensions/rv_gmaps/trunk/language/lv_LV/lang.php

    r8724 r12706  
    1313$lang['Show all']='Rādīt visu';
    1414$lang['show all photos around this location']='rādīt visus attēlus ap šo (vietu) lokāciju';
    15 $lang['Search a location...']='Meklēt lokāciju...';
    1615
    1716$lang['Loading']='Lādēšana';
  • extensions/rv_gmaps/trunk/language/nl_NL/lang.php

    r11406 r12706  
    1313$lang['Show all']='Toon alles';
    1414$lang['show all photos around this location']='toon alle afbeeldingen in de buurt van deze locatie';
    15 $lang['Search a location...']='Zoek een locatie...';
    1615
    1716$lang['Loading']='Laden';
  • extensions/rv_gmaps/trunk/language/no_NO/lang.php

    r9006 r12706  
    1313$lang['Show all']='Vis alle';
    1414$lang['show all photos around this location']='vis alle bilder rundt denne lokalisasjonen';
    15 $lang['Search a location...']='Søk på en lokalisasjon...';
    1615
    1716$lang['Loading']='Laster';
  • extensions/rv_gmaps/trunk/language/pl_PL/lang.php

    r8724 r12706  
    1414$lang['Show all']='Pokaż wszystko';
    1515$lang['show all photos around this location']='pokaż wszystkie obrazy w pobliżu tej lokalizacji';
    16 $lang['Search a location...']='Szukaj lokalizacji...';
    1716
    1817$lang['Loading']='Wczytywanie';
  • extensions/rv_gmaps/trunk/language/ru_RU/lang.php

    r9083 r12706  
    1313$lang['Show all']='Показать все';
    1414$lang['show all photos around this location']='Показать все фотографии вблизи от этой точки';
    15 $lang['Search a location...']='Поиск места...';
    1615
    1716$lang['Loading']='Загрузка';
  • extensions/rv_gmaps/trunk/language/sk_SK/lang.php

    r9480 r12706  
    1313$lang['Show all']='Zobraziť všetko';
    1414$lang['show all pictures around this location']='zobraziť fotografie v okolí';
    15 $lang['Search a location...']='Nájsť polohu...';
    1615
    1716$lang['Loading']='Nahrávanie';
  • extensions/rv_gmaps/trunk/main.inc.php

    r12701 r12706  
    11<?php /*
    22Plugin Name: RV Maps&Earth
    3 Version: 2.3.b-alpha
     3Version: 2.3.b
    44Description: Extend your gallery with Google Maps and Google Earth ...
    55Plugin URI: http://piwigo.org/ext/extension_view.php?eid=122
     
    77Author URI: http://www.modusoptimus.com/
    88*/
    9 define( 'RVM_PLUGIN_VERSION', '2.3.b-alpha');
     9define( 'RVM_PLUGIN_VERSION', '2.3.b');
    1010defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    1111
  • extensions/rv_gmaps/trunk/map_data.php

    r12698 r12706  
    132132  rvo( ",\n" );
    133133
    134   rvo( 'kml_url: "'.rvm_duplicate_kml_index_url(array('box'=>$c['bounds'], 'flat'=>1), array('start') ). '"' );
    135   rvo( ",\n" );
    136 
    137134  $max_per_cluster = rvm_get_config_var('nb_images_per_marker',20);
    138135  if ( count($c['items']) >  $max_per_cluster )
     
    160157    rvo( "{" );
    161158    rvo( "tn: ".jsgm_str( get_thumbnail_url( $img ) ) );
    162     rvo( "," );
    163     rvo( "name: ".jsgm_str( trigger_event('render_element_description', $title) ) );
    164     rvo( "," );
    165     rvo( "comment: ".jsgm_str( trigger_event('render_element_description', $img['comment']) ) );
    166     rvo( "," );
    167     rvo( "page_url: ".jsgm_str( $page_url ) );
     159    rvo( ",name: ".jsgm_str( trigger_event('render_element_description', $title) ) );
     160    rvo( ",comment: ".jsgm_str( trigger_event('render_element_description', $img['comment']) ) );
     161    rvo( ",page_url: ".jsgm_str( $page_url ) );
    168162    rvo( "}" );
    169163  }
  • extensions/rv_gmaps/trunk/template/data_handler.js

    r12701 r12706  
    1212
    1313        google.maps.event.bind( this._map, "click", this, this._onMapClick);
    14         //google.maps.event.bind( this._infoWindow, "domready", this, this._onInfoWindowDomReady);
    1514}
    1615
     
    2322_navHtmlIds: ["gotoPrevImage", "gotoNextImage"],
    2423_navHtmlHandles: [],
    25 _recursionProtect: 0,
    2624_prevResult: { nb_items:0 },
    2725
     
    7068        if (changed)
    7169        {
    72                 var newMarkers = [];
     70// BEGIN NEW ****************   
     71                var markersToRemove=[], clustersToAdd=[], newMarkers=[];
     72                data.image_clusters.sort( function(a,b) { return PwgDataHandler.cmpll( a.position, b.position); } );
     73                for (i=0; i<data.image_clusters.length; i++)
     74                {
     75                        var cluster = data.image_clusters[i];
     76                        while(this._markers.length)
     77                        {
     78                                var marker = this._markers[0];
     79                                if (PwgDataHandler.cmpll(cluster.position, marker.getPosition()) == 0)
     80                                {
     81                                        marker.pwg = {
     82                                                nb_items: cluster.nb_items,
     83                                                images: cluster.items,
     84                                                bounds: cluster.bounds,
     85                                                blowup_url: cluster.blowup_url
     86                                                };
     87                                        newMarkers.push(marker);
     88                                        this._markers.shift();
     89                                        cluster = null;
     90                                        break;
     91                                }
     92                                else if (PwgDataHandler.cmpll(cluster.position, marker.getPosition()) < 0)
     93                                {
     94                                        break;
     95                                }
     96                                else
     97                                {
     98                                        markersToRemove.push(marker);
     99                                        this._markers.shift();
     100                                }
     101                        }
     102
     103                        if (cluster)
     104                                clustersToAdd.push(cluster);
     105                }
     106
     107                if (document.is_debug) glog('reused ' + newMarkers.length + ' exact markers');
     108                markersToRemove = markersToRemove.concat( this._markers );
     109
     110                var infoWindowMarker = this._infoWindow.getAnchor();
     111                for (i=0; i<clustersToAdd.length; i++)
     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();
     121                        if (marker && marker==infoWindowMarker)
     122                        {
     123                                marker.setMap(null);
     124                                google.maps.event.clearInstanceListeners(marker);
     125                                if (document.is_debug) glog('removed marker with infoWindow');
     126                                marker = this._markers.pop();
     127                        }
     128
     129                        if (!marker)
     130                        {
     131                                marker = new google.maps.Marker(this.options.markerOptions);
     132                                marker.setPosition(cluster.position);
     133                                marker.setTitle(theTitle);
     134                                google.maps.event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) );
     135                                google.maps.event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) );
     136                                marker.setMap(this._map);
     137                        }
     138                        else
     139                        {
     140                                marker.currentImageIndex=0;
     141                                marker.setPosition( cluster.position );
     142                                marker.setTitle(theTitle);
     143                        }
     144
     145                        newMarkers.push(marker);
     146
     147                        marker.pwg = {
     148                                nb_items: cluster.nb_items,
     149                                images: cluster.items,
     150                                bounds: cluster.bounds,
     151                                blowup_url: cluster.blowup_url
     152                                };
     153                }
     154
     155                for (i=0; i<markersToRemove.length; i++)
     156                {
     157                        markersToRemove[i].setMap(null);
     158                        google.maps.event.clearInstanceListeners(markersToRemove[i]);
     159                }
     160
     161                this._markers = newMarkers;
     162                this._markers.sort( function(a,b) { return PwgDataHandler.cmpll( a.getPosition(), b.getPosition()); } );
     163// END new
     164               
     165/*              var newMarkers = [];
    73166                var infoWindowMarker = this._infoWindow.getAnchor();
    74167
     
    123216                        google.maps.event.clearInstanceListeners(this._markers[i]);
    124217                }
    125 
     218*/
    126219                this._markers = newMarkers;
    127220                this._prevResult.nb_items=data.nb_items;
     
    207300_onInfoWindowDomReady: function()
    208301{
    209         if (this._recursionProtect)
    210                 return;
    211302        if (!this._infoWindow.getAnchor() || this._infoWindow.getAnchor().pwg.images.length<2)
    212303                return;
    213         try {
    214                 this._recursionProtect = 1;
    215                 for (var i=0; i< this._navHtmlIds.length; i++)
    216                 {
    217                         var elt = document.getElementById( this._navHtmlIds[i] );
    218                         if (elt)
    219                                 this._navHtmlHandles.push( google.maps.event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, this._infoWindow.getAnchor(), i) ) );
    220                 }
    221         }
    222         finally {
    223                 this._recursionProtect = 0;
     304        for (var i=0; i< this._navHtmlIds.length; i++)
     305        {
     306                var elt = document.getElementById( this._navHtmlIds[i] );
     307                if (elt)
     308                        this._navHtmlHandles.push( google.maps.event.addDomListener(elt, "click", pwgBind(this, this._onPictureNavigate, this._infoWindow.getAnchor(), i) ) );
    224309        }
    225310},
     
    267352}
    268353
     354PwgDataHandler.cmpll = function(a,b) {
     355        var d= a.lng() - b.lng();
     356        if (d < -.5e-6)
     357                return -1;
     358        else if (d > .5e-6)
     359                return 1;
     360        d= a.lat() - b.lat();
     361        if (d < -.5e-6)
     362                return -1;
     363        else if (d > .5e-6)
     364                return 1;
     365        return 0;
     366}
    269367
    270368String.prototype.urlNoHtm = function()
  • extensions/rv_gmaps/trunk/template/data_loader.js

    r12701 r12706  
    7777        var bounds = new google.maps.LatLngBounds( this._map.getBounds().getSouthWest(), this._map.getBounds().getNorthEast() );
    7878       
    79         //bug as of v 3.7 -
     79        //BEGIN BUG in maps api as of v3.7 - when map wraps horizontally more than 360 deg - the getBounds is wrong
    8080        var isOver = false;
    8181        if (bounds.getSouthWest().lng() < bounds.getNorthEast().lng())
     
    9090                isOver = true;
    9191        }
     92        if (!isOver)
     93        {//very emprical tests
     94                if (this._map.getDiv().offsetWidth / this._map.getDiv().offsetHeight > 1.3
     95                                && this._map.getZoom()<3
     96                                && bounds.getSouthWest().lat() < -50
     97                                && bounds.getNorthEast().lat() > 50)
     98                {
     99                        isOver = true;
     100                }
     101        }
    92102       
    93103        if (isOver)
    94104                bounds = new google.maps.LatLngBounds( new google.maps.LatLng(this._map.getBounds().getSouthWest().lat(),-179.9), new google.maps.LatLng(this._map.getBounds().getNorthEast().lat(), 179.9) );
    95         //end bug
     105        //END bug
    96106       
    97107       
     
    117127        /*if ( !bounds.isFullLat() )*/
    118128        {
    119                 nd = latRange*12/100;
    120                 sd = latRange*4/100;
     129                nd = latRange*0.12;
     130                sd = latRange*0.04;
    121131        }
    122132        /*if ( !bounds.isFullLng() )*/
    123133        {
    124                 ed = lonRange*9/100;
    125                 wd = lonRange*7/100;
     134                ed = lonRange*0.09;
     135                wd = lonRange*0.07;
    126136        }
    127137        var digits = Math.max( getLatLonDigits(latRange,4,2), getLatLonDigits(lonRange,4,2) );
  • extensions/rv_gmaps/trunk/template/map.tpl

    r12701 r12706  
    77<title>{$GALLERY_TITLE}</title>
    88
    9 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;language={$lang_info.code}" type="text/javascript"></script>
     9<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;language={$lang_info.code}&amp;libraries=places" type="text/javascript"></script>
    1010
    1111{combine_script id='jquery' load='header' path='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'}
     
    5151        if (console)
    5252        {
    53                 console.log(msg + " b="+map.getBounds().toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() );
     53                var b = map.getBounds();
     54                if (b)
     55                        console.log(msg + " b="+b.toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() );
     56                else
     57                        console.log(msg);
    5458        }
    5559}
     
    111115
    112116        map.pwgDataLoader.start( "{/literal}{$U_MAP_DATA}{literal}" );
     117       
     118        var ac = new google.maps.places.Autocomplete( document.getElementById('q') );
     119        ac.bindTo('bounds', map);
     120        google.maps.event.addListener(ac, 'place_changed', function() {
     121                var place = ac.getPlace();
     122                if (place.geometry.viewport) {
     123                        map.fitBounds(place.geometry.viewport);
     124                } else {
     125                        map.setCenter(place.geometry.location);
     126                        map.setZoom(17);  // Why 17? Because it looks good.
     127                }
     128        } );
    113129}
    114130
     
    198214                </a>
    199215    <span class="gmnoprint">
    200                         <form action="#" onsubmit="if (this.q.value!='' &amp;&amp; this.q.value!='{'Search a location...'|@translate|@escape:javascript}') searchLocation(this.q.value);return false;">
    201                                 <input type="text" size="32" name="q"
    202                                         value="{'Search a location...'|@translate}"
    203                                         onfocus="if (value=='{'Search a location...'|@translate|@escape:javascript}') value='';"
    204                                         onblur="if (value=='') value='{'Search a location...'|@translate|@escape:javascript}'" />
    205                                 <input type="submit" value="{'Search'|@translate}"/>
    206                         </form>
     216                        <input type="text" size="48" id="q" />
    207217                </span>
    208218  </div>
  • extensions/rv_gmaps/trunk/template/picture_map_content.tpl

    r10082 r12706  
    11
    22{html_head}
    3 <script src="http://maps.google.com/maps/api/js?sensor=false&amp;hl={$lang_info.code}" type="text/javascript"></script>
     3<script src="http://maps.google<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;language={$lang_info.code}" type="text/javascript"></script>
    44{combine_script id='jquery' load='header' path='themes/default/js/jquery.min.js'}
    55{combine_script id='jquery.nyroModal' load='async' path="`$PLUGIN_LOCATION`/template/nyroModal/jquery.nyroModal-1.6.2.js" version='1.6.2'}
  • extensions/rv_gmaps/trunk/template/style.css

    r3447 r12706  
    4949}
    5050
    51 #titlebar FORM {
    52   display:inline;
    53   margin:0;
    54 }
    55 
    56 #titlebar FORM INPUT {
     51#titlebar INPUT {
    5752  border: 1px solid gray;
    5853  font-size:80%;
    59 }
    60 
    61 #titlebar FORM INPUT {
    6254  color: #404040;
    6355  background-color: #dddddd;
    6456}
    6557
    66 #titlebar FORM INPUT:focus {
     58
     59#titlebar INPUT:focus {
    6760  color: black;
    6861  background-color: #ffffff;
Note: See TracChangeset for help on using the changeset viewer.