Changeset 8466


Ignore:
Timestamp:
Jan 4, 2011, 2:24:50 PM (13 years ago)
Author:
cljosse
Message:

[edit_gmaps] clean up.


Location:
extensions/edit_gmaps/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/edit_gmaps/admin/admin_edit.php

    r8456 r8466  
    229229                $lat=$location[1];
    230230                $lon=$location[0];
     231                $adresse ="Europe";
     232                if (date_default_timezone_get()) {
     233                        $adresse = date_default_timezone_get()  ;
     234                }
     235         
    231236
    232237                                $template->assign(      array('lat' => $lat ,
     
    235240                                                   array('LAT' => $lat,
    236241                                                                                 'LON' => $lon,
     242                                                                                  'ADRESSE' => $adresse,
    237243                                                                                )
    238244                                                                        );
     
    240246                                                                       
    241247  foreach ($collection as $id_0)  {
     248                $adresse ="Europe/Paris";
     249                if (date_default_timezone_get()) {
     250                        $adresse ="'" . date_default_timezone_get() ."'" ;
     251                }
     252         
     253
    242254                foreach ($images as $image)  {
    243255
     
    251263                                                   array('LAT' => $lat,
    252264                                                                                 'LON' => $lon,
     265                                                                                   'ADRESSE' => $adresse,
    253266                                                                                )
    254267                                                                        );
  • extensions/edit_gmaps/admin/admin_edit.tpl

    r8456 r8466  
    44{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js" }
    55{known_script id="jquery.cluetip" src=$ROOT_URL|@cat:"themes/default/js/plugins/jquery.cluetip.packed.js"}
    6 {known_script id="EDIT_RV_script" src=$EDIT_RV_ROOT|@cat:"js/JScript.js"}
    7  
     6
     7{known_script id="jquery.ui"      src=$ROOT_URL|@cat:"themes/default/js/ui/ui.core.js"}
     8{known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.resizable.js"}
     9{known_script id="EDIT_RV_script" src=$EDIT_RV_ROOT|@cat:"js/JScript.js"}
    810
    911<script src="http://maps.google.com/maps/api/js?sensor=false&amp;hl={$lang_info.code}" type="text/javascript"></script>
     
    1214
    1315<style type="text/css">{literal}
     16#cadre{  background-color:Beige; border-width:5px;
     17 left:0px;
     18  width:500px;
     19  height:500px;
     20 
     21}
    1422
    15 #map2{   
    16 left:0px;
    17  width:250px
    18 }
    19 #mapPicture{
    20 
    21 width:100px ;
    22  border:outset;
    23  height:100px;
    24 }
    25 #map{ float:left;
    26  top:20px;
    27  right:0px;
    28   width:500px;
     23#map{
     24 left:0px;
     25  width:100%;
    2926  height:500px;
    3027 border:outset;
     
    108105
    109106<input class="cluetip" title="{'search_title'|@translate}|{'hlp_line6'|@translate}."  type="submit" name="submit" value="{'search_title'|@translate}"  onclick="codeAddress()"  />
    110 <input class="cluetip" title="{'lieu'|@translate}|{'hlp_line5'|@translate}." type="text" size="70"   value="{$match}"  name="match"      />
     107<input class="cluetip" title="{'lieu'|@translate}|{'hlp_line5'|@translate}." type="text" size="70"   value="{$match}"  name="match"   id="match"    />
    111108
    112109{if $lat}
     
    119116
    120117    <div id="map"></div>
     118
    121119    {if not empty($Selectthumbnails)}
    122120            <ul class="thumbnails">
     
    146144             <script type="text/javascript">
    147145            {if isset($coordinates) && $coordinates.LAT != 100 }
    148                          var   coordinates={ldelim} LAT:{$coordinates.LAT},LON:{$coordinates.LON} };
     146                         var   coordinates={ldelim}
     147                 LAT:{$coordinates.LAT},
     148                 LON:{$coordinates.LON},
     149                 ADRESSE:{$coordinates.ADRESSE}
     150                 };
     151           
    149152            {else}
    150                          var  coordinates={ldelim} LAT:100,LON:100 }; 
     153                         var  coordinates={ldelim}
     154                 LAT:100,
     155                 LON:100,
     156                 ADRESSE:{$coordinates.ADRESSE}
     157                  }; 
    151158            {/if}
    152159           
     
    184191</form>
    185192
    186 
    187 <script type="text/javascript">
    188 jQuery().ready(
    189   function(){ldelim}
    190   jQuery('.cluetip').cluetip({ldelim}
    191     width: 300,height:100,
    192     splitTitle: '|'
    193    }
    194   );
    195  }
    196 );
    197 </script>
    198 
     193 
  • extensions/edit_gmaps/admin/js/JScript.js

    r8456 r8466  
    33var geocoder;
    44var map;
    5 var infowindow = new google.maps.InfoWindow();
    65var marker;
    7 
    8 function onLoad()
    9             {
     6var markers = new Array;
     7var detect = navigator.userAgent.toLowerCase();
     8
     9function onLoad() {
     10    var reg = new RegExp('/', "g");
     11   
     12  coordinates.ADRESSE=  coordinates.ADRESSE.replace("/",", ");
     13
     14          document.getElementById("match").value = coordinates.ADRESSE;
    1015                geocoder = new google.maps.Geocoder();
    1116                    var mapElement = document.getElementById("map");
    1217             if  ( coordinates.LAT  <= 90 ) {
    13                  LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
     18               
     19                 n = coordinates.ADRESSE.indexOf("/");
     20                 if (n>0)
     21                     zoom = 5;
     22                     else
    1423                            zoom = 18 ;
    15              }else {
    16                             LatLng = new google.maps.LatLng(49, 3);
    17                             zoom = 3;
     24                        } else {
     25                            coordinates.LAT=49 ;coordinates.LON = 3;
     26                       
     27                            geocoder.geocode({ 'address': coordinates.ADRESSE }, function (results, status) {
     28                                /* Si l'adresse a pu être géolocalisée */
     29                                if (status == google.maps.GeocoderStatus.OK) {
     30                                    /* Récupération de sa latitude et de sa longitude */
     31                                    coordinates.LAT = results[0].geometry.location.lat();
     32                                    coordinates.LON = results[0].geometry.location.lng();
     33                                    LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
     34                                    updateMarkerPosition(LatLng);
     35                                    geocodePosition(LatLng);
     36                                }
     37                            });
     38                 
     39                            zoom = 4;
    1840                        }
    1941 
    20 
     42   LatLng = new google.maps.LatLng(coordinates.LAT, coordinates.LON);
     43 
    2144
    2245            /*
     
    3255                    };
    3356       
    34                     var map = new google.maps.Map( mapElement, mapOpts );
     57                    map = new google.maps.Map( mapElement, mapOpts );
    3558
    3659             
     
    3861
    3962         if (coordinates)
    40                     var marker = new google.maps.Marker( {
     63                   marker = new google.maps.Marker( {
    4164                            position: map.getCenter(),
    4265                            map: map,
     
    7093
    7194
     95
    7296                        // Update current position info.   
    7397                       updateMarkerPosition(LatLng);
    7498                       geocodePosition(LatLng);
    7599             
    76                     return false;
     100                  return false;
    77101   
    78102
    79             function blowupUrl(theUrl) {
    80                 var win = new Window({
    81                     title: document.title,
    82                     url: theUrl,
    83                     classname: "alphacube",
    84                     left: 0, top: 0,
    85                     width: "640", height: "480",
    86                     minimizable: false,
    87                     maximizable: false,
    88                     draggable: false,
    89                     resizable: true,
    90                     destroyOnClose: true,
    91                     hideEffect: Element.hide,
    92                     showEffectOptions: { duration: 1.5 }
    93                 })
    94                 win.setConstraint(true, { top: 20, left: 20, bottom: 30, right: 20 });
    95                 win.maximize();
    96                 win.showCenter(true, 20, 20);
    97              
    98             }
    99 
    100 
    101 
    102 
    103 
    104       infowindow = new google.maps.InfoWindow();
    105 
    106       function geocodePosition(pos) {
    107           m = typeof geocoder;
    108             if (m == "undefined" ) return;
    109         geocoder.geocode({     
    110                 'latLng': pos    },
    111                 function(responses) {     
    112                     if (responses && responses.length > 0) {       
    113                         updateMarkerAddress(responses[0].formatted_address);
    114                     } else {       
    115                         updateMarkerAddress('Cannot determine address at this location.');     
    116                       }   
    117                 });
    118        }   
    119        
     103 
     104
     105
     106 }
     107
    120108       function updateMarkerStatus(str) {   
    121109                document.getElementById('markerStatus').innerHTML = str;
     
    129117           
    130118           function updateMarkerAddress(str) {               
    131                  message =  str;
    132                  document.getElementById('markerAdress').innerHTML = str;
    133 
    134             }
    135 
    136 
     119                  document.getElementById('markerAdress').innerHTML = str;
     120
     121            }
     122
     123
     124       
     125
     126
     127        function geocodePosition(pos) {
     128            geocoder.geocode({ 'latLng': pos },
     129               function (results, status) {
     130                   /* Si le géocodage inversé a réussi */
     131                   if (status == google.maps.GeocoderStatus.OK) {
     132                       updateMarkerAddress(results[0].formatted_address);
     133                   } else {
     134                       updateMarkerAddress('Cannot determine address at this location.');
     135                   }
     136               });
    137137        }
    138138
    139 
    140139 
    141 
    142 
    143 
    144      
    145   /* Initialisation de la carte  */
    146         function initialize() {
    147             geocoder = new google.maps.Geocoder();
    148             var latlng = new google.maps.LatLng(40.730885, -73.997383);
    149             var myOptions = {
    150                 zoom: 8,
    151                 center: latlng,
    152                 mapTypeId: 'roadmap'
    153             }
    154             map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    155         }
    156 
    157 
    158140        /* Fonction de géocodage déclenchée en cliquant surle bouton "Geocoder"  */
    159141        function codeAddress() {
    160142            /* Récupération de la valeur de l'adresse saisie */
     143         
     144            /* Appel au service de geocodage avec l'adresse en paramètre */
     145            if (typeof map == "undefined") onLoad();
     146
    161147            var address = document.getElementById("match").value;
    162             /* Appel au service de geocodage avec l'adresse en paramètre */
    163             geocoder.geocode({ 'address': address }, function (results, status) {
    164                 /* Si l'adresse a pu être géolocalisée */
    165                 if (status == google.maps.GeocoderStatus.OK) {
    166                     /* Récupération de sa latitude et de sa longitude */
    167                     document.Envoie.lat.value = results[0].geometry.location.lat();
    168                     document.Envoie.lon.value = results[0].geometry.location.lng();
    169                     map.setCenter(results[0].geometry.location);
    170                     /* Affichage du marker */
    171                     var marker = new google.maps.Marker({
    172                         map: map,
    173                         position: results[0].geometry.location
    174                     });
    175                     /* Permet de supprimer le marker précédemment affiché */
    176                     markers.push(marker);
    177                     if (markers.length > 1)
    178                         markers[(i - 1)].setMap(null);
    179                     i++;
    180                 } else {
    181                     alert("Le geocodage n\'a pu etre effectue pour la raison suivante: " + status);
    182                 }
     148
     149  geocoder.geocode({ 'address': address }, function (results, status) {
     150      /* Si l'adresse a pu être géolocalisée */
     151      if (status == google.maps.GeocoderStatus.OK) {
     152          /* Récupération de sa latitude et de sa longitude */
     153          coordinates.LAT = results[0].geometry.location.lat();
     154          coordinates.LON = results[0].geometry.location.lng();
     155          onLoad();
     156         
     157           
     158
     159      } else {
     160          alert("Cannot determine location at this adress.: " + status);
     161      }
     162  });
     163        }
     164
     165
     166
     167
     168        jQuery().ready(function () {
     169
     170
     171            jQuery('.cluetip').cluetip({
     172                width: 300, height: 100,
     173                splitTitle: '|'
     174            }
     175  );
     176
     177            // Resize possible 
     178            jQuery("#cadre").resizable({
     179                handles: "all",
     180                animate: true,
     181                animateDuration: "slow",
     182                animateEasing: "swing",
     183                preventDefault: true,
     184                preserveCursor: true,
     185                autoHide: true,
     186                ghost: true
    183187            });
    184         }
    185 
    186 
    187 
    188   /* Fonction de géocodage inversé  */
    189   function codeLatLng() {
    190    var lat = parseFloat(document.Envoie.lat.value);
    191    var lng = parseFloat(document.Envoie.lon.value);
    192    var latlng = new google.maps.LatLng(lat, lng);
    193 
    194    geocoder.geocode({ 'latLng': latlng },
    195               function(results, status) {
    196                     /* Si le géocodage inversé a réussi */
    197                     if (status == google.maps.GeocoderStatus.OK) {
    198                      if (results[1]) {
    199                         map.setZoom(11);
    200                         marker = new google.maps.Marker({
    201                         position: latlng,
    202                         map: map
    203                        });
    204       /* Affichage de l'infowindow sur le marker avec l'adresse récupérée */
    205       infowindow.setContent(results[1].formatted_address);
    206       infowindow.open(map, marker);
    207      }
    208     } else {
    209      alert("Le geocodage a echoue pour la raion suivante : " + status);
    210     }
    211    });
    212   }
    213  
     188
     189            jQuery("#match").keydown(function (e) {
     190
     191                // e.target         pour FireFox
     192                // event.srcElement pour IE
     193                var Obj = e ? e.target : event.srcElement;
     194                if (Obj.tagName != "INPUT") return false;
     195
     196
     197                var Code = e.keyCode || e.which;
     198                if (Code != 13) return true;
     199                    coordinates.ADRESSE=   document.getElementById("match").value  ;
     200                    codeAddress();
     201                return false;
     202            });
     203
     204
     205        });
     206
Note: See TracChangeset for help on using the changeset viewer.