var geocoder;
var map;
var picto = {
url: 'https://www.ideal-audicion.es/images/pointer-off-v8.png',
size: new google.maps.Size(36, 51),
//// The origin for this image is (0, 0).
origin: new google.maps.Point(0, 0),
// //The anchor for this image is the base of the flagpole at (0, 32).
anchor: new google.maps.Point(18, 51)
};
function Right(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else {
var iLen = String(str).length;
return String(str).substring(iLen, iLen - n);
}
}
function Left(str, n){
if (n <= 0)
return "";
else if (n > String(str).length)
return str;
else
return String(str).substring(0,n);
}
function zoom_moi() {
map.setZoom(12);
maville=document.getElementById('contact_dest').value;
//if (maville=="Paris-16") {malat=48.842500;malng=2.268769;}
if (maville=="Sevilla") {
malat=37.3898446;
malng=-5.9986476;
}
//if (maville=="Paris-5") {malat=48.842406;malng=2.352222;}
//if (maville=="Paris-8") {malat=48.874688;malng=2.325452;}
//if (maville=="Paris-11") {malat=48.866248;malng=2.365635;}
//if (maville=="Paris-12") {malat=48.840004;malng= 2.381365;}
//if (maville=="Paris-14") {malat=48.8328453;malng= 2.3314642999999933;}
//if (maville=="Paris-15") {malat=48.838803;malng=2.299962 ;}
//if (maville=="Paris-17") {malat=48.883154;malng=2.307254;}
//if (maville=="Paris-18") {malat=48.892917;malng=2.342354;}
//if (maville=="Paris-19") {malat=48.882028;malng=2.371088;}
//if (maville=="Paris-20") {malat=48.865620;malng=2.397730;}
//if (maville=="Charenton-le-Pont") {malat=48.821845;malng=2.419615;}
//if (maville=="Melun") {malat=48.539543;malng=2.663083;}
//if (maville=="St-Germain-En-Laye") {malat=48.898430;malng=2.089033;}
//if (maville=="Asnieres-sur-Seine") {malat=48.909098;malng=2.285191;}
//if (maville=="Nanterre") {malat=48.893483;malng=2.195524;}
//if (maville=="Pierrefitte") {malat=48.965683;malng=2.360774;}
//if (maville=="Nogent-sur-Marne") {malat=48.836812;malng=2.482612;}
//if (maville=="Mantes-la-Jolie") {malat=48.990123;malng=1.716249;}
//if (maville=="Puteaux") {malat=48.880053;malng=2.239082;}
//if (maville=="Lille") {malat=50.636735;malng=3.062298;}
//if (maville=="Nantes") {malat=47.212098;malng=-1.559720;}
//if (maville=="Nice") {malat=43.700333;malng=7.270217;}
//if (maville=="Meaux") {malat=48.959578;malng=2.881217;}
//if (maville=="Paris-16vh") {malat=48.867734;malng=2.280222;}
//if (maville=="Toulouse") {malat=43.600796;malng=1.448480;}
//if (maville=="Boulogne") {malat=48.8325991;malng=2.244220700000028;}
//if (maville=="Argenteuil") {malat=48.9447097;malng=2.2502623000000312;}
//if (maville=="Vincennes") {malat=48.848092;malng=2.437397;}
//if (maville=="Limoges") {malat=45.831878;malng=1.258647;}
//if (maville=="Sarcelles") {malat=48.978796;malng=2.371779;}
//if (maville=="Colombes") {malat=48.924080;malng=2.253701;}
//if (maville=="Neuilly-sur-Seine") {malat=48.883133;malng=2.266826;}
//if (maville=="Bagnolet") {malat=48.865312;malng=2.415361;}
//if (maville=="Rambouillet") {malat=48.645044;malng=1.821050;}
//if (maville=="Rueil-Malmaison") {malat=48.877318;malng=2.181475;}
map.panTo({lat: malat, lng: malng});
window.setTimeout(function() {
map.setZoom(13);
//map.setCenter({lat: 50.636735, lng: 3.062298});
}, 300);
}
//zoom_moi(50.636735,3.062298)
function initialize() {
geocoder = new google.maps.Geocoder();
var myOptions = {
zoom: 6,
//center: {lat: 48.903997, lng: 2.357833},
center: {lat: 40.41696160600785, lng: -3.7035773981880356},
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var picto = {
url: 'https://www.ideal-audicion.es/images/pointer-off-v8.png',
size: new google.maps.Size(36, 51),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(18, 51)
};
}
function codeAddress(address,ville) {
if (geocoder) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (geocoder) {
var vindex=1;
var lien_sevilla='Acceso desde este Centro';
if (ville=='sevilla') {
lien_sevilla='';
}
var myLatLng0 = new google.maps.LatLng(37.3898446, -5.9986476);
var marker0 = new google.maps.Marker({map: map, icon: picto ,title: 'Ideal Audición Sevilla', position: myLatLng0 ,zIndex: vindex});
var contentString0 = '
Ideal Audición Sevilla
Calle San Pablo 21
41001 Sevilla
'+lien_sevilla+'
';
var infowindow0 = new google.maps.InfoWindow({ content: contentString0 });
if (ville=='sevilla') {
//infowindow0.open(map,marker0);
infowindow0.open({
anchor: marker0,
map,
shouldFocus: false,
});
}
google.maps.event.addListener(marker0, 'click', function() {
//infowindow0.open(map,marker0);
infowindow0.open({
anchor: marker0,
map,
shouldFocus: true,
});
$('#contact_dest option[value="Sevilla"]').prop('selected', true);
});
}
else {
/*alert("Problème de Géo-localisation, raison : " + status);*/
/*alert("Avez-vous bien renseigné votre adresse de départ ?");*/
}
});
}
}
function MonAddress(address) {
$("#map-panel").html(' Patientez svp ...');
if (geocoder) {
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
/*map.setCenter(results[0].geometry.location);*/
var myLatLng0 = results[0].geometry.location;
$('#map-panel').empty();
/*alert(results[0].geometry.location);*/
/*var img = new google.maps.MarkerImage('https://www.ideal-audicion.es/images/charenton.png', new google.maps.Size(80, 40), new google.maps.Point(0,0), new google.maps.Point(17, 37));*/
var MonMarker = new google.maps.Marker({position: results[0].geometry.location, map: map, title: address ,zIndex: 2 });
var myLatLngDest = new google.maps.LatLng(48.821845, 2.419615);
if (document.getElementById('contact_dest').value=='0') {
document.getElementById('contact_dest').value='Charenton-le-Pont';
}
var myLatLng1 = new google.maps.LatLng(37.3898446, -5.9986476);
if (document.getElementById('contact_dest').value=='Sevilla') {
myLatLngDest=myLatLng1;
}
var contentString0 = '';
var infowindow0 = new google.maps.InfoWindow({
content: contentString0
});
google.maps.event.addListener(MonMarker, 'mouseover', function() {
infowindow0.open(map,MonMarker);
});
///////////
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer({ 'map': map, draggable:true });
var request = {
origin : myLatLng0,
destination: myLatLngDest,
travelMode : google.maps.DirectionsTravelMode.DRIVING,
/*travelMode : google.maps.DirectionsTravelMode.TRANSIT,*/
unitSystem: google.maps.DirectionsUnitSystem.METRIC
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
directionsDisplay.setOptions({'suppressMarkers':true});
directionsDisplay.setOptions({polylineOptions:{strokeColor: '#008000'}, preserveViewport: false});
directionsDisplay.setPanel(document.getElementById("map-panel"));
}
});
//////////
}
else {
/*alert("Avez-vous bien renseigné votre adresse de départ ?");*/
if (confirm("No has introducido tu dirección de Salida, ¿quieres utilizar la geolocalización?")) {
localisemoi();
}
else {
$('#map-panel').empty();
$("#map-panel").html('Para obtener su itinerario: ingrese una dirección de salida o acepte Geolocalización');
}
}
});
}
}
function success(position) {
var geolocate = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
/* var MonMarkerLocal = new google.maps.Marker({position: geolocate, map: map, title: 'En su casa' ,zIndex: 2 });
var contentString0 = '';
var infowindow0 = new google.maps.InfoWindow({
content: contentString0
});
google.maps.event.addListener(MonMarkerLocal, 'mouseover', function() {
infowindow0.open(map,MonMarkerLocal);
}); */
//var infowindow = new google.maps.InfoWindow({
//map: map,
//position: geolocate,
//content:
//'vous êtes ici
' +
//'Latitude: ' + position.coords.latitude + '
' +
//'Longitude: ' + position.coords.longitude + '
'
//});
map.setCenter(geolocate);
var myLatLngDepart = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
var myLatLngDest = new google.maps.LatLng(48.821845, 2.419615);
if (document.getElementById('contact_dest').value=='0') {
document.getElementById('contact_dest').value='Charenton-le-Pont';
}
var myLatLng1 = new google.maps.LatLng(37.3898446, -5.9986476);
if (document.getElementById('contact_dest').value=='Sevilla') {
myLatLngDest=myLatLng1;
}
//var contentString0 = '';
//var infowindow0 = new google.maps.InfoWindow({
// content: contentString0
//});
//google.maps.event.addListener(MonMarkerLocal, 'mouseover', function() {
//infowindow0.open(map,MonMarkerLocal);
//});
$('#map-panel').empty();
///////////
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer({ 'map': map, draggable:true });
var request = {
origin : myLatLngDepart,
destination: myLatLngDest,
travelMode : google.maps.DirectionsTravelMode.DRIVING,
//travelMode : google.maps.DirectionsTravelMode.TRANSIT,
unitSystem: google.maps.DirectionsUnitSystem.METRIC
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
directionsDisplay.setOptions({'suppressMarkers':true});
directionsDisplay.setOptions({polylineOptions:{strokeColor: '#008000'}, preserveViewport: false});
directionsDisplay.setPanel(document.getElementById("map-panel"));
}
});
//////////
showLocation(position);
}
function errorMsg(error) {
msg = {
1: "Acceso al puesto no autorizado",
2: "Posición no encontrada",
3: "Tiempo expiró"
}
//map-panel.innerHTML = msg[error.code]
$('#map-panel').empty();
$("#map-panel").html("Lo siento ! "+msg[error.code])+"
";
//alert(error.code);
}
function localisemoi() {
if(!!navigator.geolocation) {
$("#map-panel").html(' Espera por favor... Geolocalización en curso siempre que la hayas autorizado y que tu navegador admita esta función.');
//var map;
//var mapOptions = {
//zoom: 15,
//mapTypeId: google.maps.MapTypeId.ROADMAP
//};
//map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
navigator.geolocation.getCurrentPosition(success, errorMsg, {timeout:30000});
}
else {
//document.getElementById('map_canvas').innerHTML = 'No Geolocation Support.';
$('#map-panel').empty();
$("#map-panel").html('Para obtener su itinerario: ingrese una dirección de salida o acepte Geolocalización');
}
}
function showLocation(pos){
var latLng = new google.maps.LatLng(pos.coords.latitude,pos.coords.longitude);
if (geocoder) {
geocoder.geocode({'latLng': latLng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
//$("mon_adresse").innerHTML = results[1].formatted_address;
//$("#mon_adresse").value = results[1].formatted_address;
var ad = results[0].formatted_address;
$("#mon_adresse").val(ad);
//alert(results[1].formatted_address);
var MonMarkerLocal = new google.maps.Marker({position: latLng, map: map, title: 'En su casa' ,zIndex: 2 });
var contentString0 = '';
var infowindow0 = new google.maps.InfoWindow({
content: contentString0
});
google.maps.event.addListener(MonMarkerLocal, 'mouseover', function() {
infowindow0.open(map,MonMarkerLocal);
});
}
}
});
}
}