Changeset 12700 for extensions


Ignore:
Timestamp:
Dec 7, 2011, 5:39:56 AM (12 years ago)
Author:
rvelices
Message:

rv_gmaps towards full maps api v3 migration

Location:
extensions/rv_gmaps/trunk
Files:
2 added
12 edited

Legend:

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

    r3447 r12700  
    2626$template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
    2727
    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';*/
    3030
    3131?>
  • extensions/rv_gmaps/trunk/admin/admin_config.php

    r8367 r12700  
    66if ( isset($_POST['submit']) )
    77{
    8   $query = '
     8  if (isset($_POST['gmaps_api_key']))
     9  {
     10    $query = '
    911UPDATE '.CONFIG_TABLE.'
    1012  SET value="'.$_POST['gmaps_api_key'].'"
    1113  WHERE param="gmaps_api_key"
    1214  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  }
    1518
     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 
    1631  $gm_config = rvm_get_config();
    1732
     
    4257      'NB_GEOTAGGED' => $nb_geotagged,
    4358      'GMAPS_API_KEY' => $conf['gmaps_api_key'],
     59      'GMAPS_AUTO_SYNC' => isset($conf['gmaps_auto_sync']) ? 1:0,
    4460      'NB_MARKERS' => rvm_get_config_var('nb_markers',40),
    4561      'NB_IMAGES_PER_MARKER' => rvm_get_config_var('nb_images_per_marker',20),
  • extensions/rv_gmaps/trunk/admin/admin_config.tpl

    r8471 r12700  
    44<form method="post" action="" class="properties">
    55<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
    1927  <li>
    2028  <label>
     
    2432    <br/><small>The images will be "clustered" based on this number and the visible region on the map.</small>
    2533  </li>
    26  
     34
    2735  <br/>
    28  
     36
    2937  <li>
    3038  <label>
  • extensions/rv_gmaps/trunk/include/functions.php

    r3447 r12700  
    3636function rvm_make_map_picture_url($params)
    3737{
    38         global $conf;
    39         if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
    40                 return "";
    4138        $map_url = make_picture_url($params);
    4239        return add_url_params($map_url, array('map'=>null) );
     
    4542function rvm_duplicate_map_picture_url()
    4643{
    47         global $conf;
    48         if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
    49                 return "";
    5044        $map_url = duplicate_picture_url();
    5145        return add_url_params($map_url, array('map'=>null) );
     
    5549{
    5650        global $conf, $rvm_dir;
    57         if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' )
    58                 return "";
    5951        $url = get_root_url().'map';
    6052        if ($conf['php_extension_in_urls'])
  • extensions/rv_gmaps/trunk/main.inc.php

    r12367 r12700  
    106106                        global $rvm_dir;
    107107                        $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,
    112110                                        $map_url, $link_title, ' target="_top"', 'map', 'map'
    113111                                ));
    114                         }
    115112                }
    116113        }
  • extensions/rv_gmaps/trunk/template/data_handler.js

    r12698 r12700  
    1111                , opts || {} );
    1212
    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);
    1415}
    1516
     
    2122_markers: [],
    2223_navHtmlIds: ["gotoPrevImage", "gotoNextImage"],
    23 _timerBindPictureNavigation: null,
     24_navHtmlHandles: [],
     25_recursionProtect: 0,
    2426_prevResult: { nb_items:0 },
    2527
     
    6971        {
    7072                var newMarkers = [];
    71                 var infoWindowMarker = this._infoWindow.pwgMarker;
     73                var infoWindowMarker = this._infoWindow.getAnchor();
    7274
    7375                for (i=0; i<data.image_clusters.length; i++)
     
    8486                        if (marker && marker==infoWindowMarker)
    8587                        {
    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);
    9090                                if (document.is_debug) glog('removed marker with infoWindow');
    9191                                marker = this._markers.pop();
     
    9595                        {
    9696                                marker = new google.maps.Marker(this.options.markerOptions);
    97         marker.setPosition(cluster.position);
    98         marker.setTitle(theTitle);
     97                                marker.setPosition(cluster.position);
     98                                marker.setTitle(theTitle);
    9999                                google.maps.event.addListener( marker, "click", pwgBind(this, this._onMarkerClick, marker) );
    100100                                google.maps.event.addListener( marker, "dblclick", pwgBind(this, this._onMarkerDblClick, marker) );
    101         marker.setMap(this._map);
    102101                        }
    103102                        else
     
    106105                                marker.setPosition( cluster.position );
    107106                                marker.setTitle(theTitle);
    108                                 marker.setMap(this._map);
    109107                        }
     108                        marker.setMap(this._map);
    110109
    111110                        newMarkers.push(marker);
     
    122121                {
    123122                        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]);
    126124                }
    127125
    128126                this._markers = newMarkers;
    129 
    130127                this._prevResult.nb_items=data.nb_items;
    131128        }
     
    136133_onMarkerClick: function( marker )
    137134{
    138         if (this._infoWindow.pwgMarker == marker )
     135        if (this._infoWindow.getAnchor() == marker )
    139136                return; // already open
    140137        var content = "";
     
    160157        content += '<div id="pwgImageDetail">' + this.buildCurrentPictureHtml( marker ) + '</div>';
    161158
     159        var h;
     160        while (h = this._navHtmlHandles.pop())
     161                google.maps.event.removeListener(h);
     162
    162163        this._infoWindow.setContent( content );
    163164        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 );
    171166},
    172167
     
    174169{
    175170        this._map.fitBounds( marker.pwg.bounds );
     171},
     172
     173_onMapClick: function( marker )
     174{
     175        this._infoWindow.close();
    176176},
    177177
     
    204204
    205205
    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;
    216223        }
    217224},
  • extensions/rv_gmaps/trunk/template/data_loader.js

    r12698 r12700  
    44        this.options = jQuery.fn.extend(
    55                {
    6                         reload_data_timeout: 500,
     6                        reload_data_timeout: 200,
    77                        rectangle_of_confusion: new google.maps.Size(32,16)
    88                }
     
    9292                        if ( this._map.getZoom() <= this._previousLoadDataReq.zoom )
    9393                                return;
    94                         else
    95                         {
    96                                 if (
    97                                         this._map.getZoom() == this._previousLoadDataReq.zoom + 1
    98                                         && 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                 else
    107                 {
    10894                }
    10995        }
  • extensions/rv_gmaps/trunk/template/map.tpl

    r12698 r12700  
    5959        var mapOptions = {
    6060                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))
    6566        {
    6667{/literal}
     
    106107                );
    107108
    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" } );
    109110        google.maps.event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) );
    110111
  • 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;
     1return {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;
     1return {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;
     1return {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  
    11function PageLinker(map, aElementId)
    22{
    3   this._map = map;
    4   this._elementId = aElementId;
     3        this._map = map;
     4        this._elementId = aElementId;
    55
    6   google.maps.event.bind( this._map, "idle", this, this._regenerateUrl );
    7   google.maps.event.bind( this._map, "maptypeid_changed", this, 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 );
    88}
    99
    1010PageLinker.getQueryVars = function()
    1111{
    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;
     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;
    2323};
    2424
    2525PageLinker.map2Url = function( map )
    2626{
    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();
     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();
    3434
    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;
     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;
    4646};
    4747
    4848PageLinker.url2Map = function( mapOptions )
    4949{
    50   var vars = PageLinker.getQueryVars();
    51   if ( !( (vars['z'] && vars['ll']) || vars['t'] ) )
    52     return false;
     50        var vars = PageLinker.getQueryVars();
     51        if ( !( (vars['z'] && vars['ll']) || vars['t'] ) )
     52                return false;
    5353
    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;
    7369}
    7470
Note: See TracChangeset for help on using the changeset viewer.