1 2 3 function ubicarMapa(iddirgoogle,msgerror,formnamefocus){ 4 5 // Obtenemos la dirección y la asignamos a una variable 6 var dirgoogle = $('#'+iddirgoogle).val(); 7 if (dirgoogle==''){ 8 alert(msgerror); 9 formnamefocus.focus(); 10 } 11 else { 12 ubicarDireccion(dirgoogle); 13 } 14 } 15 16 /** 17 * ubicarDireccion(address) 18 * Función que ubica el mapa en un punto dado a partir de una dirección 19 * Recibe: la dirección 20 **/ 21 function ubicarDireccion(address){ 22 // Creamos el Objeto Geocoder 23 var geocoder = new google.maps.Geocoder(); 24 // Hacemos la petición indicando la dirección e invocamos la función geocodeResult enviando todo el resultado obtenido 25 geocoder.geocode({ 'address': address}, geocodeResult); 26 } 27 28 /** 29 * geocodeResult(address) 30 * Función que obtiene las coordenadas a partir de una dirección 31 **/ 32 function geocodeResult(results, status) { 33 34 if (status == 'OK') { //Si hay resultados 35 36 // fitBounds acercará el mapa con el zoom adecuado de acuerdo a lo buscado 37 map.fitBounds(results[0].geometry.viewport); 38 39 if(marker!=null) { marker.setMap(null);} //Si ya hay un marcador lo borramos 40 41 // Dibujamos un marcador con la ubicación del primer resultado obtenido 42 marker=new google.maps.Marker({ //creamos un nuevo marcador para el mapa 43 map:map, 44 position:results[0].geometry.location, 45 draggable:true // con esto indicamos que se puede mover 46 } 47 ); 48 49 marker.setMap(map); 50 51 var lat_aux=results[0].geometry.location.lat(); 52 var long_aux=results[0].geometry.location.lng(); 53 actualizarCamposMapa(lat_aux,long_aux); 54 55 google.maps.event.addListener(marker, "dragend", function() { 56 //Evento que se ejecuta al mover el marcador 57 actualizarCamposMapa(marker.getPosition().lat(),marker.getPosition().lng()); 58 }); 59 60 } else { 61 // En caso de no haber resultados o que haya ocurrido un error 62 // lanzamos un mensaje con el error 63 alert("No hay resultados: " + status); 64 } 65 66 } 67 68 /** 69 * actualizarCamposMapa(latitudaux,longitudaux) 70 * Función que actualiza los campos del formulario relacionados con el mapa 71 * Recibe: latitud y longitud, arrastar para controlar si se llama a la función desde el arrastrar del punto 72 **/ 73 function actualizarCamposMapa(latitudaux,longitudaux){ 74 75 var valorselet_long="1"; //value a seleccionar de <select> tipolongitud, por defecto NORTE (+) 76 var valorselet_lat="1"; //value a seleccionar de <select> tipolongitud, por defecto ESTE (+) 77 78 if (latitudaux<0){ 79 latitudaux=-(latitudaux); 80 valorselet_lat="-1"; //Seleccionamos opción SUR (-) 81 } 82 83 if (longitudaux<0){ 84 longitudaux=-(longitudaux); 85 valorselet_long="-1"; //Seleccionamos opción OESTE (-) 86 } 87 88 document.getElementById("latitud").value=latitudaux; 89 document.getElementById("longitud").value=longitudaux; 90 91 if ( $("#tipolatitud").length > 0 ) { 92 $("#tipolatitud option[value="+ valorselet_lat +"]").attr("selected",true); 93 } 94 95 if ( $("#tipolongitud").length > 0 ) { 96 $("#tipolongitud option[value="+ valorselet_long +"]").attr("selected",true); 97 } 98 99 if ( $("#long_formato_1").length > 0 ) { 100 $('#long_formato_1').attr('checked','checked'); 101 } 102 103 if ( $("#lat_formato_1").length > 0 ) { 104 $('#lat_formato_1').attr('checked','checked'); 105 } 106 107 if ($("#opcionmapa_1").length > 0 ) { 108 if ($("#direcciongoogle").val()!='') { 109 $('#opcionmapa_1').attr('checked','checked'); 110 } else { 111 $('#opcionmapa_1').attr('checked',false); 112 } 113 } 114 115 if ( $("#opcionmapa_2").length > 0 ) { 116 $('#opcionmapa_2').attr('checked','checked'); 117 } 118 119 } 120 121 /** 122 * cambiarTipoMapa(opcion) 123 * Función que cambia el tipo de mapa en función del valor que se le pase por parámetro 124 * Recibe: opcion: 1--> mapa, 2--> satelite, 3-->híbrido 125 **/ 126 function cambiarTipoMapa(opcion) { 127 128 if (opcion==1) { map.setMapTypeId(google.maps.MapTypeId.ROADMAP); } // mapa 129 130 if (opcion==2) { map.setMapTypeId(google.maps.MapTypeId.SATELLITE); } //satelite 131 132 if (opcion==3) { map.setMapTypeId(google.maps.MapTypeId.HYBRID); } //híbrido 133 } 134 135 /** 136 * cambiarZoom(valorzoom) 137 * Función que cambia el zoom del mapa 138 * Recibe: valor del zoom 139 **/ 140 function cambiarZoom (valorzoom) { 141 map.setZoom(parseInt(valorzoom));
142 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.