Foros del Web » Programando para Internet » Jquery »

Problema para cargar mismo mapa en otro html

Estas en el tema de Problema para cargar mismo mapa en otro html en el foro de Jquery en Foros del Web. Hola amigos, estoy programando una plataforma de itinerarios turísticos y tengo un problema, cuando cargo otra pestaña que me lleva a otro html, lo que ...
  #1 (permalink)  
Antiguo 11/11/2013, 15:52
 
Fecha de Ingreso: noviembre-2013
Mensajes: 2
Antigüedad: 10 años, 5 meses
Puntos: 0
Problema para cargar mismo mapa en otro html

Hola amigos, estoy programando una plataforma de itinerarios turísticos y tengo un problema, cuando cargo otra pestaña que me lleva a otro html, lo que pasa es que tengo programado un calculador de ruta con google maps y cuando clikeo en la pestaña me lleva al otro html y se pierde la ruta trazada en la pagina anterior, quería saber como puedo hacer que cargue el mismo mapa al darle click a la otra pestaña. aquí dejo el código que estoy usando.

de antemano muchas gracias.

<meta charset="UTF-8" />
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
function calculateRoute(from, to) {
// Center initialized to villarica
var myOptions = {
zoom: 10,
center: new google.maps.LatLng(-39.397, -70.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Draw the map
var mapObject = new google.maps.Map(document.getElementById("map-canvas"), myOptions);

var directionsService = new google.maps.DirectionsService();
var directionsRequest = {
origin: from,
destination: to,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC
};
directionsService.route(
directionsRequest,
function(response, status)
{
if (status == google.maps.DirectionsStatus.OK)
{
new google.maps.DirectionsRenderer({
map: mapObject,
directions: response
});
}
else
$("#error").append("Unable to retrieve your route<br />");
}
);
}

$(document).ready(function() {
// If the browser supports the Geolocation API
if (typeof navigator.geolocation == "undefined") {
$("#error").text("Your browser doesn't support the Geolocation API");
return;
}

$("#from-link, #to-link").click(function(event) {
event.preventDefault();
var addressId = this.id.substring(0, this.id.indexOf("-"));

navigator.geolocation.getCurrentPosition(function( position) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
"location": new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
$("#" + addressId).val(results[0].formatted_address);
else
$("#error").append("Unable to retrieve your address<br />");
});
},
function(positionError){
$("#error").append("Error: " + positionError.message + "<br />");
},
{
enableHighAccuracy: true,
timeout: 10 * 1000 // 10 seconds
});
});

$("#calculate-route").submit(function(event) {
event.preventDefault();
calculateRoute($("#from").val(), $("#to").val());
});
});
</script>

Etiquetas: ajax, html, javascript, js, mapa
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:16.