Changeset 9377 for extensions/edit_gmaps/admin
- Timestamp:
- Feb 25, 2011, 12:44:14 PM (13 years ago)
- Location:
- extensions/edit_gmaps/admin
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/edit_gmaps/admin/admin.php
r8501 r9377 3 3 include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 4 4 5 $colonnes = cl_get_columns_of(IMAGES_TABLE); 6 $key = array_search('alt', $colonnes[IMAGES_TABLE]); 7 if (!$key){ 8 $q = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN `alt` DOUBLE(9,6)'; 9 pwg_query($q); 10 } 11 /** 12 * list all columns of each given table 13 * 14 * @return array of array 15 */ 16 function cl_get_columns_of($table) 17 { 18 $columns_of = array(); 19 $query = 'DESC '.$table.';'; 20 $result = mysql_query($query); 21 $columns_of[$table] = array(); 22 23 if ($result) 24 while ($row = mysql_fetch_row($result)) 25 array_push($columns_of[$table], $row[0]); 26 27 return $columns_of; 28 } 29 30 5 31 $template->set_filename('plugin_admin_content', dirname(__FILE__).'/admin.tpl'); 6 32 7 33 if (!isset($_GET['tab'])) 8 $page['tab'] = ' config';34 $page['tab'] = 'edit'; 9 35 else 10 36 $page['tab'] = $_GET['tab']; 11 $page['tab'] = 'edit'; 37 12 38 $my_base_url = get_admin_plugin_menu_link(__FILE__); 13 39 14 40 $tabsheet = new tabsheet(); 15 41 $tabsheet->add( 'edit', 'Edit', add_url_params( $my_base_url, array('tab'=>'edit') ) ); 42 //$tabsheet->add( 'edit_meta', 'Edit_meta', add_url_params( $my_base_url, array('tab'=>'edit_meta') ) ); 16 43 $tabsheet->select($page['tab']); 17 44 $tabsheet->assign(); … … 24 51 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); 25 52 26 27 53 ?> -
extensions/edit_gmaps/admin/admin_edit.php
r8960 r9377 14 14 include (dirname(__FILE__).'\element_set.php'); 15 15 16 17 18 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 19 20 21 /***********************************************************************************/ 22 if (!defined('TOOL_KIT_PATH')) define( 'TOOL_KIT_PATH', EDIT_RV_PATH."admin/"); 23 if (!defined('INCLUDE_PATH')) define( 'INCLUDE_PATH', TOOL_KIT_PATH.'include/' ); 24 $Toolkit_Dir =INCLUDE_PATH ; 25 26 include $Toolkit_Dir . 'fonctions.php'; 27 /***********************************************************************************/ 28 29 16 30 $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']); 17 if ( isset($_POST['submit']) and !is_adviser() ) 31 32 33 if ( isset($_POST['submit']) ) 18 34 { 19 35 $collection = array(); 20 36 if( !isset ($_POST['target'])) 21 37 { 22 $_POST['submit'] == l10n('Submit') ;23 $_POST['target']='selection';24 $collection = $_POST['selection'];38 $_POST['submit'] == l10n('Submit') ; 39 $_POST['target']='selection'; 40 $collection = $_POST['selection']; 25 41 26 42 } … … 37 53 $collection = $_POST['selection']; 38 54 break; 39 } 40 55 } 41 56 42 57 // test si mise à jour (valider) … … 47 62 $lat = trim($_POST['lat']); 48 63 $lon = trim($_POST['lon']); 49 64 $alt = trim($_POST['alt']); 65 50 66 if ( strlen($lat)>0 and strlen($lon)>0 ) 51 67 { … … 61 77 $page['errors'][] = 'Both lat/lon must be empty or not empty'; 62 78 79 if ( strlen($alt)==0) 80 $update_query .= ', alt=NULL'; 81 else 82 $update_query .= ', alt=' .$alt ; 83 84 85 63 86 if (isset($update_query)) 64 87 { … … 67 90 WHERE id IN ('.implode(',',$collection).')'; 68 91 pwg_query($update_query); 69 cl m_invalidate_cache();92 cl_meta_invalidate_cache(); 70 93 } 71 94 } … … 127 150 { 128 151 $query=' 129 SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.'152 SELECT id,tn_ext,name,path,file,lat,lon,alt FROM '.IMAGES_TABLE.' 130 153 WHERE id IN ('.implode(',',$page['cat_elements_id']).') 131 154 '.$conf['order_by'].' … … 157 180 158 181 //========================================================== 159 if (!defined('EDIT_RV_ ROOT')) define( 'EDIT_RV_ROOT', PHPWG_PLUGINS_PATH.'edit_gmaps/admin/' );182 if (!defined('EDIT_RV_PATH')) define( 'EDIT_RV_PATH', EDIT_RV_PATH .'admin/' ); 160 183 $path = EDIT_RV_PATH; 161 184 $plg_data = implode( '', file($path.'main.inc.php') ); 162 185 if (preg_match("|Version: (.*)|", $plg_data, $val)) 163 { $ edit_rv_plugin['version'] = trim($val[1]); }164 $edit_rv_plugin = array_map('htmlspecialchars', $edit_rv_plugin);165 $version= $edit_rv_plugin['version'] ;166 167 186 { $EDIT_RV_PATH_plugin['version'] = trim($val[1]); } 187 $EDIT_RV_PATH_plugin = array_map('htmlspecialchars', $EDIT_RV_PATH_plugin); 188 $version= $EDIT_RV_PATH_plugin['version'] ; 189 $icon_path = 'themes/default/icon/help.png'; 190 $path_js= 'themes/default/js/' ; 168 191 169 192 //================================================================================== 170 193 $match=""; 171 if ( isset($_POST['submit']) and !is_adviser())194 if ( isset($_POST['submit']) ) 172 195 { 173 196 … … 191 214 $src=""; 192 215 $template->assign( 193 array( 'EDIT_RV_ ROOT' => EDIT_RV_ROOT,216 array( 'EDIT_RV_PATH' => EDIT_RV_PATH, 194 217 'path_js' => $path_js, 195 218 'VERSION'=> $version, 196 'EDIT_RV_ ROOT_ABS' => dirname(__FILE__).'/',219 'EDIT_RV_PATH_ABS' => dirname(__FILE__).'/', 197 220 ) 198 221 ); … … 209 232 'ADRESSE' => $adresse, 210 233 'ZOOM' => 18, 234 'ALT' => 0 235 ) 236 ); 237 $filename =""; 238 239 if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' )) 240 { 241 if (isset($collection)) 242 { $lat =1000; 243 foreach ($collection as $id_0) { 244 foreach ($images as $image) { 245 if (array_search($id_0,$image)) { 246 $_POST['selection'] = $collection ; 247 248 $infos_gps= Get_exif_gps( $image['path'],$image) ; 249 if( $image['lat'] == ''){ 250 $image['lat']=$infos_gps['lat']; 251 $image['lon']=$infos_gps['lon']; 252 $image['alt']=$infos_gps['alt']; 253 }else { 254 $image['lat']=$infos_gps['lat']; 255 $image['lon']=$infos_gps['lon']; 256 $image['alt']=$infos_gps['alt']; 257 } 258 $filename= $image; 259 260 261 if ($lat==1000) { 262 $lat= ($image['lat'] <> '') ? $image['lat'] : '100' ; 263 $lon= ($image['lon'] <> '') ? $image['lon'] : '3.0' ; 264 $alt= ($image['alt'] <> '') ? $image['alt'] : '0' ; 265 if($lat != '100') $lat=$image['lat']; 266 //===================================================== 267 $template->assign( 'coordinates', 268 array('LAT' => $lat , 269 'LON' => $lon , 270 'ADRESSE' => $adresse , 271 'ZOOM' => 4, 272 'ALT' => $alt , 211 273 ) 212 274 ); 213 if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' ))214 {215 216 if (isset($collection))217 {218 $lat =1000;219 foreach ($collection as $id_0) {220 foreach ($images as $image) {221 if (array_search($id_0,$image)) {222 $_POST['selection'] = $collection ;223 224 if ($lat==1000) {225 $lat1= ($image['lat'] <> '') ? $image['lat'] : '100' ;226 $lon1= ($image['lon'] <> '') ? $image['lon'] : '3.0' ;227 if($lat1 != '100') $lat=$image['lat'];228 229 $template->assign( 'coordinates',230 array('LAT' => $lat1 ,231 'LON' => $lon1 ,232 'ADRESSE' => $adresse ,233 'ZOOM' => 4,234 )235 );236 237 275 } 238 239 $tpl_var = array_merge( 276 $lonDMS= dec2dms($lon) ; 277 $latDMS= dec2dms($lat) ; 278 if ($infos_gps['lat']=="") 279 $icon='icon/minus.png'; 280 else $icon='icon/minus.png'; 281 282 $tpl_var = array_merge( 240 283 $image, 241 284 array( 242 'lat' => $image['lat'] , 243 'lon' => $image['lon'] , 285 'icon' => $icon , 286 'lat' => $image['lat'] , 287 'lon' => $image['lon'] , 288 'alt' => $image['alt'] , 289 'latDMS' => $latDMS[3] , 290 'lonDMS' => $lonDMS[3] , 244 291 'adresse' => $adresse , 245 292 'U_TN' => get_thumbnail_url($image), … … 260 307 } 261 308 } 262 } 263 309 310 } 311 312 313 if ( !empty($filename)) 314 { 315 // document.Envoie.latDMS.value 316 $image= $filename ; 317 $filename= $filename['path'] ; 318 $Val_exif=""; 319 $Val_XMP=""; 320 // error_reporting ( 0 ); 321 // Hide any unknown EXIF tags 322 /* 323 $GLOBALS['HIDE_UNKNOWN_TAGS'] = FALSE; 324 include $Toolkit_Dir . 'Toolkit_Version.php'; // Change: added as of version 1.11 325 include $Toolkit_Dir . 'JPEG.php'; // Change: Allow this example file to be easily relocatable - as of version 1.11 326 include $Toolkit_Dir . 'JFIF.php'; 327 include $Toolkit_Dir . 'PictureInfo.php'; 328 include $Toolkit_Dir . 'XMP.php'; 329 include $Toolkit_Dir . 'Photoshop_IRB.php'; 330 include $Toolkit_Dir . 'EXIF.php'; 331 332 $jpeg_header_data = get_jpeg_header_data($filename ); 333 */ 334 if (!empty($infos_gps)) 335 $Position = $infos_gps ; 336 337 else $Position = Get_exif_gps($filename,$image) ; 338 339 340 341 $template->assign( array( 342 'filename_abs' => $filename , 343 'filename' => $filename, 344 'datas' => array( 345 /* 'Val_JPEG_APP'=> Generate_JPEG_APP_Segment_HTML( $jpeg_header_data ), 346 'Val_intrinsic'=> Interpret_intrinsic_values_to_HTML( get_jpeg_intrinsic_values( $jpeg_header_data ) ), 347 'Val_Comment'=> Interpret_Comment_to_HTML( $jpeg_header_data ), 348 'Val_JFIF'=> Interpret_JFIF_to_HTML( get_JFIF( $jpeg_header_data ), $filename ), 349 'Val_JFXX'=>Interpret_JFXX_to_HTML( get_JFXX( $jpeg_header_data ), $filename ), 350 'Val_App12' => Interpret_App12_Pic_Info_to_HTML( $jpeg_header_data ), 351 'Val_IRB' => Interpret_IRB_to_HTML( get_Photoshop_IRB( $jpeg_header_data ), $filename ), 352 353 'Val_exif'=> Interpret_EXIF_to_HTML( get_EXIF_JPEG( $filename ), $filename), 354 'Val_XMP' => Interpret_XMP_to_HTML( read_XMP_array_from_text( get_XMP_text( $jpeg_header_data) ) ), 355 */ 356 // 357 ), 358 'Datadase' => ($Position) , 359 ) ); 360 } 361 362 function Memo_vars($variables) 363 { 364 ob_start(); 365 echo '<pre>'; 366 print_r($variables); 367 echo '</pre>'; 368 $m= ob_get_contents(); 369 370 ob_end_clean(); 371 return $m; 372 373 } 264 374 //======================================================================= 265 375 function cl_make_map_picture_url($params) … … 271 381 return add_url_params($map_url, array('map'=>null) ); 272 382 } 273 ?> 383 $v1=0; 384 385 386 function Get_exif_gps($filename,$image) 387 { 388 error_reporting ( 1 ); 389 $datas = array(); 390 $errors = array(); 391 // 392 393 // $Exif_array = get_EXIF_JPEG( $filename ); 394 // if ( empty($Exif_array) ) return; 395 396 $exif = @read_exif_data( $filename ); 397 398 399 if ( empty($exif) ) return; 400 $exif = array_intersect_key( $exif, array_flip( array('GPSLatitudeRef', 'GPSLatitude', 'GPSLongitudeRef', 'GPSLongitude', 'GPSAltitudeRef', 'GPSAltitude') ) ); 401 402 403 error_reporting ( 1 ); 404 /* 405 if ( count($exif)<4) 406 return; 407 408 409 if ( !in_array($exif['GPSLatitudeRef'], array('S', 'N') ) ) 410 { 411 $errors[] = $filename. ': GPSLatitudeRef not S or N'; 412 return; 413 } 414 if ( !in_array($exif['GPSLongitudeRef'], array('W', 'E') ) ) 415 { 416 $errors[] = $filename. ': GPSLongitudeRef not W or E'; 417 return; 418 } 419 if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) ) 420 { 421 $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays'; 422 return; 423 } 424 */ 425 426 427 $lat = $image['lat'] ; 428 $lon = $image['lon'] ; 429 $alt=$image['alt']; 430 431 if ($lat =="") 432 { 433 $lat = Parse_Lat_Lon( $exif['GPSLatitude'] ); 434 if ( $exif['GPSLatitudeRef']=='S' )$lat = -$lat; 435 $latDMS=$exif['GPSLatitude'][0] . " | " . $exif['GPSLatitude'][1]. " | " . $exif['GPSLatitude'][2] ; 436 437 }else{ 438 439 if($lat<0) $exif['GPSLatitudeRef']='S' ; 440 else $exif['GPSLatitudeRef']='N' ; 441 $latDMS=dec2dms($lat); 442 $exif['GPSLatitude']= $latDMS ; 443 } 444 global $errors; 445 if (!is_array($exif['GPSLatitude']) or !is_array($exif['GPSLongitude']) ) 446 { 447 $errors[] = $filename. ': GPSLatitude and GPSLongitude are not arrays'; 448 //return; 449 } 450 451 if ($lon =="") { 452 453 $lon = parse_lat_lon( $exif['GPSLongitude'] ); 454 $lonDMS= $exif['GPSLongitude'][0] . " | " . $exif['GPSLongitude'][1] . " | " . $exif['GPSLongitude'][2] ; 455 if ( $exif['GPSLongitudeRef']=='W' ) $lon = -$lon; 456 }else{ 457 if ($lon<0) $exif['GPSLongitudeRef'] ='W' ; 458 else $exif['GPSLongitudeRef'] ='E' ; 459 $lonDMS=dec2dms($lon); 460 $exif['GPSLongitude']=$lonDMS ; 461 } 462 463 464 465 //======================================================================= 466 $altref = 0; 467 468 if (!is_array($exif['GPSAltitude']) or !is_array($exif['GPSAltitudeRef']) ) 469 { 470 $exif['GPSAltitude']=$alt; 471 $exif['GPSAltitudeRef']=0; 472 } else { 473 $alt = $exif['GPSAltitude']; 474 $altref = $exif['GPSAltitudeRef']; 475 } 476 //======================================================================== 477 478 $datas[] = array ( 479 ' filename=' => $filename , 480 'id' => $image['id'] , 481 'lat' => $lat , 482 'lon' => $lon , 483 'latDMS' => $exif['GPSLatitude'][0]['Numerator'] . "/" . 484 $exif['GPSLatitude'][0]['Denominator'] . " " . 485 $exif['GPSLatitude'][1]['Numerator'] . "/" . 486 $exif['GPSLatitude'][1]['Denominator']. " " . 487 $exif['GPSLatitude'][2]['Numerator'] . "/" . 488 $exif['GPSLatitude'][2]['Denominator'], 489 'lonDMS' => $exif['GPSLongitude'][0]['Numerator'] . "/" . 490 $exif['GPSLongitude'][0]['Denominator'] . " " . 491 $exif['GPSLongitude'][1]['Numerator'] . "/" . 492 $exif['GPSLongitude'][1]['Denominator']. " " . 493 $exif['GPSLongitude'][2]['Numerator'] . "/" . 494 $exif['GPSLongitude'][2]['Denominator'], 495 'altref' => $exif['GPSAltitudeRef'], 496 'alt' => $exif['GPSAltitude'] , 497 498 ); 499 500 return $datas[0] ; 501 } 502 ?> -
extensions/edit_gmaps/admin/admin_edit.tpl
r8960 r9377 2 2 {* $Id: admin_edit.tpl 2011-01-03 *} 3 3 {if PHPWG_VERSION < 2.2 } {include 4 file=$EDIT_RV_ ROOT_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_ROOT_ABS|@cat:'header_2_2.tpl'}4 file=$EDIT_RV_PATH_ABS|@cat:'header_2_1.tpl'} {else} {include file= $EDIT_RV_PATH_ABS|@cat:'header_2_2.tpl'} 5 5 {/if} 6 6 … … 14 14 LON:'{$coordinates.LON}', 15 15 ADRESSE:'{$coordinates.ADRESSE}', 16 ZOOM:18 16 ZOOM:18, 17 ALT:'{$coordinates.ALT}' 17 18 }; 18 19 {else} … … 21 22 LON:' ', 22 23 ADRESSE:'{$coordinates.ADRESSE}', 23 ZOOM:4 24 ZOOM:4, 25 ALT:' ' 24 26 }; 25 27 {/if} … … 29 31 }); 30 32 31 // Event.observe(window, 'load', onLoad );33 32 34 33 35 </script> … … 166 168 167 169 <label>{'Form'|@translate}</label> 168 <table >170 <table > 169 171 <td > 170 172 … … 173 175 <input class="cluetip" title="{'lieu'|@translate}|{'hlp_line5'|@translate}." type="text" size="70" value="{$match}" name="match" id="match" /> 174 176 </td> 175 <tr> 176 <td> 177 <table > 178 <tr> <input type="text" size="15" value="{$filename}" name="filename" /> 179 <td > 177 180 <label>Latitude (-90=S to 90=N)</label> 178 <input type="text" size=" 8" value="{$lat}" name="lat" />181 <input type="text" size="15" value="{$lat}" name="lat" /> 179 182 </td> 180 183 <td> 181 184 <label>Longitude (-180=E to 180=W) </label> 182 <input type="text" size="9"value="{$lon}" name="lon" /> 183 </td> 184 </tr><tr> 185 186 <td><input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td> 185 <input type="text" size="15"value="{$lon}" name="lon" /> 186 </td> 187 <td> 188 <label>Altitude </label> 189 <input type="hidden" size="2"value="0" name="altRef" /> 190 <input type="text" size="15"value="{$alt}" name="alt" /> <label> m </label> 191 </td> 192 </tr> 193 </table> 194 <tr> 195 <table > 196 <tr> 197 <td > 198 <label>Latitude DMS</label><input type="text" size="3" value="{$latRef}" name="latRef" /> 199 <input type="text" size="25" value="{$latDMS}" name="latDMS" /> 200 </td> 201 <td> 202 <label>Longitude DMS </label><input type="text" size="3" value="{$lonRef}" name="lonRef" /> 203 <input type="text" size="25"value="{$lonDMS}" name="lonDMS" /> 204 </td> 205 206 </tr> 207 </table> 208 <tr> 209 210 <td> 211 <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" {$tag_input_enabled} /></td> 187 212 </td></tr> 188 213 </table> … … 198 223 </fieldset> 199 224 </fieldset> 200 201 225 </form> 226 227 <fieldset style="display:none"> 228 <form name="EditJPEG" id="EditJPEG" action="{$EDIT_RV_PATH}Write_File_Info_Gps.php" method="post"> 229 <input name="filename" size="60" id="filename" name="filename" type="test" value="../../../{$filename}" /> 230 <table> 231 <tr> 232 <td> 233 Latitude Ref 234 </td> 235 <td> 236 <input size="60" id="latRef" name="GPSLatitudeRef" type="text" value="{$latRef}"> 237 </td> 238 239 <td> 240 Latitude 241 </td> 242 <td> 243 <input size="60" id="latDMS" name="GPSLatitude" type="text" value="{$latDMS}"> 244 </td> 245 </tr> 246 <tr> 247 <td> 248 Longitude Ref 249 </td> 250 <td> 251 <input size="60" id="lonRef" name="GPSLongitudeRef" type="text" value="{$lonRef}"> 252 </td> 253 254 <td> 255 Longitude 256 </td> 257 <td> 258 <input size=60 id="lonDMS" name="GPSLongitude" type=\"text\" value="{$lonDMS}"> 259 </td> 260 </tr> 261 <tr> 262 <td> 263 Altitude Ref 264 </td> 265 <td> 266 <input size=60 id="altRef" name="GPSAltitudeRef" type=\"text\" value="{$altRef}"> 267 </td> 268 <td> 269 Altitude 270 </td> 271 <td> 272 <input size=60 id="alt" name="GPSAltitude" type=\"text\" value="{$alt}"> 273 </td> 274 </tr> 275 </table> 276 <br> 277 <input type="submit" value="Update!"> 278 </form> 279 </fieldset> -
extensions/edit_gmaps/admin/header_2_1.tpl
r8960 r9377 3 3 {known_script id="jquery.ui" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.core.js"} 4 4 {known_script id="jquery.ui.resizable" src=$ROOT_URL|@cat:"themes/default/js/ui/ui.resizable.js"} 5 {known_script id="EDIT_RV_script" src=$EDIT_RV_ ROOT|@cat:"js/JScript.js"}6 {known_script id="fieldset" src=$EDIT_RV_ ROOT|@cat:"js/fieldset.js"}5 {known_script id="EDIT_RV_script" src=$EDIT_RV_PATH|@cat:"admin/js/JScript.js"} 6 {known_script id="fieldset" src=$EDIT_RV_PATH|@cat:"admin/js/fieldset.js"} -
extensions/edit_gmaps/admin/header_2_2.tpl
r8960 r9377 7 7 8 8 9 {combine_script id="EDIT_RV_script" path=$EDIT_RV_ ROOT|@cat:"js/JScript.js" require="jquery"}10 {combine_script id="fieldset" path=$EDIT_RV_ ROOT|@cat:"js/fieldset.js" require="jquery"}9 {combine_script id="EDIT_RV_script" path=$EDIT_RV_PATH|@cat:"admin/js/JScript.js" require="jquery"} 10 {combine_script id="fieldset" path=$EDIT_RV_PATH|@cat:"admin/js/fieldset.js" require="jquery"} -
extensions/edit_gmaps/admin/js/JScript.js
r8501 r9377 80 80 81 81 google.maps.event.addListener(marker, 82 'dragend', 83 function () { 84 updateMarkerStatus('Drag ended'); 85 geocodePosition(marker.getPosition()); 86 87 } 82 'dragend', 83 function () { 84 85 86 87 // getElevation({ latLng: marker.getPosition() }); 88 geocodePosition(marker.getPosition()); 89 updateMarkerStatus('Drag ended'); 90 getElevation({ 'latLng': marker.getPosition() }); 91 document.Envoie.alt.value = coordinates.ALT; 92 93 } 88 94 ); 89 95 90 91 92 // Update current position info. 96 // styleIcon = new StyledIcon(StyledIconTypes.BUBBLE, { color: "#cccccc", text: "Drag Me!" }); 97 // var styleMaker1 = new StyledMarker({ styleIcon: styleIcon, position: new google.maps.LatLng(37.383477473067, -121.880502070713), map: map, draggable: true }); 98 99 // google.maps.event.addDomListener(styleMaker1, "dragend", getElevation); 100 // Update current position info. 101 93 102 updateMarkerPosition(LatLng); 94 103 geocodePosition(LatLng); 95 104 getElevation({ 'latLng': marker.getPosition() }); 105 document.Envoie.alt.value = coordinates.ALT; 96 106 return false; 97 107 … … 109 119 document.Envoie.lat.value=latLng.lat() ; 110 120 document.Envoie.lon.value = latLng.lng(); 111 112 121 dms_frac = dec2dms(latLng.lng()); 122 if (dms_frac.Degre < 0) 123 document.Envoie.lonRef.value = "W"; 124 else 125 document.Envoie.lonRef.value = "E"; 126 document.Envoie.lonDMS.value = Math.abs(dms_frac.Degre) +"/1" + " " + dms_frac.Minute +"/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator; 127 dms_frac = dec2dms(latLng.lat()); 128 if (dms_frac.Degre < 0) 129 document.Envoie.latRef.value = "S"; 130 else 131 document.Envoie.latRef.value = "N"; 132 document.Envoie.latDMS.value = Math.abs(dms_frac.Degre) + "/1" + " " + dms_frac.Minute + "/1" + " " + dms_frac.Numerator + "/" + dms_frac.Denominator; 133 update_datas(); 134 } 135 136 137 function update_datas() { 138 n= jQuery(document.EditJPEG); 139 140 jQuery.each(n[0], function (i) { 141 142 143 n00 = this; 144 n0 = n00.id; 145 n1 = n00.name; 146 n2 = jQuery(n00).val(); 147 try { 148 if (n0 == "alt") { 149 n3 = dec2frac(document.Envoie[n0].value); 150 n3 = n3.Numerator + "/" + n3.Denominator; 151 jQuery(this).val(n3); 152 } 153 else { 154 n3 = document.Envoie[n0].value; 155 jQuery(this).val(n3); 156 } 157 } 158 catch (e) { 159 n3 = n0; 160 } 161 162 163 164 } 165 ) 166 167 168 113 169 } 114 170 … … 119 175 } 120 176 121 122 123 124 125 function geocodePosition(pos) { 126 geocoder.geocode({ 'latLng': pos }, 127 function (results, status) { 177 function getElevation(event) { 178 var elevator = new google.maps.ElevationService(); 179 var locations = []; 180 181 // Retrieve the clicked location and push it on the array 182 var clickedLocation = event.latLng; 183 locations.push(clickedLocation); 184 185 // Create a LocationElevationRequest object using the array's one value 186 var positionalRequest = { 187 'locations': locations 188 } 189 190 // Initiate the location request 191 if (elevator) { 192 elevator.getElevationForLocations(positionalRequest, function (results, status) { 193 if (status == google.maps.ElevationStatus.OK) { 194 195 // Retrieve the first result 196 if (results[0]) { 197 coordinates.ALT = results[0].elevation; 198 document.Envoie.alt.value = coordinates.ALT; 199 update_datas(); 200 //styleIcon.set("text", "Elevation: " + results[0].elevation + "m"); 201 } else { 202 // alert("No results found"); 203 } 204 } else { 205 alert("Elevation service failed due to: " + status); 206 } 207 }); 208 } 209 } 210 211 212 213 function geocodePosition(pos) { 214 geocoder.geocode({ 'latLng': pos }, 215 function (results, status) { 128 216 /* Si le géocodage inversé a réussi */ 129 217 if (status == google.maps.GeocoderStatus.OK) { … … 198 286 199 287 coordinates = { ADRESSE: jQuery("#match").val(), 200 LAT:0,LON:0,ZOOM: 18 288 LAT:0,LON:0,ZOOM: 18 ,ALT:0 201 289 }; 202 290 codeAddress(); … … 212 300 if (Code != 13) return true; 213 301 coordinates = { ADRESSE: jQuery("#match").val(), 214 LAT:0,LON:0,ZOOM: 18302 LAT: 0, LON: 0, ZOOM: 18, ALT: 0 215 303 }; 216 304 codeAddress(); … … 221 309 }); 222 310 311 312 313 314 // DECIMAL TO FRACTION 315 // 316 function dec2frac( valeur_decimal ) { 317 decimal = valeur_decimal.toString() ; 318 num = ''; 319 den = 1; 320 dec = false; 321 322 // find least reduced fractional form of number 323 for( i = 0, ix = decimal.length ; i < ix; i++ ) 324 { 325 // build the denominator as we 'shift' the decimal to the right 326 if( dec ) den *= 10; 327 328 // find the decimal place/ build the numberator 329 if( decimal.charAt(i) == '.' ) dec = true; 330 else num += decimal.charAt(i); 331 } 332 num = parseInt(num); 333 334 // whole number, just return it 335 if( den == 1 ) return num; 336 337 num2 = num; 338 den2 = den; 339 rem = 1; 340 // Euclid's Algorithm (to find the gcd) 341 while( num2 % den2 ) { 342 rem = num2 % den2; 343 num2 = den2; 344 den2 = rem; 345 } 346 if( den2 != den ) rem = den2; 347 ret1 = { Numerator: (num / rem), Denominator: (den / rem) }; 348 // new Array() 349 // ret1->Numerator =(num / rem ) ; 350 // ret1->Denominator=(den / rem); 351 352 // now $rem holds the gcd of the numerator and denominator of our fraction 353 return ret1; 354 355 } 356 357 function dec2dms(l) { 358 sign = 1; 359 if (l < 0) { sign = -1; } 360 l = Math.abs(Math.round(l * 1000000.)) 361 d = Math.floor(l / 1000000) * sign; 362 m = Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60); 363 s = Math.floor(((((l / 1000000) - Math.floor(l / 1000000)) * 60) - Math.floor(((l / 1000000) - Math.floor(l / 1000000)) * 60)) * 100000) * 60 / 100000; 364 frac_s = dec2frac(s); 365 s2 = (frac_s.Numerator / frac_s.Denominator); 366 return { dms: d + "° " + m + "' " + s + "''", 367 Degre:d, Minute:m,Sec:s, 368 Numerator: frac_s.Numerator, 369 Denominator:frac_s.Denominator}; 370 } 371
Note: See TracChangeset
for help on using the changeset viewer.