1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
| /////////////////////////////////////////////////
function recherchercaf(){
var latlng;
var pos ;
initialize();
function initialize() {
var mapOptions = {
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
latlng = new google.maps.Map(document.getElementById('carte'),
mapOptions);
// Try HTML5 geolocation
if(navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
pos = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var infowindow = new google.maps.InfoWindow({
map: latlng,
position: pos,
content: 'you are here '
});
return (pos);
}, function() {
handleNoGeolocation(true);
});
} else {
// Browser doesn't support Geolocation
handleNoGeolocation(false);
}
return (pos);
}
function handleNoGeolocation(errorFlag) {
if (errorFlag) {
var content = 'Error: The Geolocation service failed.';
} else {
var content = 'Error: Your browser doesn\'t support geolocation.';
}
var options = {
map: latlng,
position: new google.maps.LatLng(60, 105),
content: content
};
var infowindow = new google.maps.InfoWindow(options);
latlng.setCenter(options.position);
}
initialize();
alert(pos);
google.maps.event.addDomListener(window, 'load', initialize);
// Paramétrage des marqueurs
var image = "images/location.png"
function initialiser() {
// Récupération de la latitude et longitude
// Récupération en AJAX des données des lieux à épingler sur la carte Google map
$.ajax({
url : 'coffeesearch.php',
error : function(request, error) { // Info Debuggage si erreur
alert("Erreur sous genre - responseText: "+request.responseText);
},
data : {cofename : $('input:text').val()},
type : 'POST',
dataType : "json",
success : function(data){
$("#carte").fadeIn('slow');
var infowindow = new google.maps.InfoWindow();
var marker, i;
// Parcours des données reçus depuis le fichier index-map-ajax.php
// Récupération de LatLng, Hint et Legende de chaque lieu et création d'un marqueur
$.each(data.items, function(i,item){
if (item) {
if (item.LatLng_lieu!=''){
// On sépare la latitude et la longitude
var strLatLng = item.LatLng_lieu.split(',');
//initialiser l carte
//creer un maqueur pour l'emplacement
marker = new google.maps.Marker({
position : new google.maps.LatLng(strLatLng[0], strLatLng[1]),
map : latlng,
icon : image,
draggable : true,
title : item.Titre_lieu
});
// afficher les info de l'emplacement
var posit = new google.maps.LatLng(strLatLng[0], strLatLng[1]);
latlng.setCenter(posit);
var line = new google.maps.Polyline({
path: [new google.maps.LatLng(35.834637,10.593392), new google.maps.LatLng(strLatLng[0], strLatLng[1])],
strokeColor: "#FF0000",
strokeOpacity: 1.0,
strokeWeight: 7,
geodesic: true,
map: latlng
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
// Affichage de la légende de chaque lie
}
})(marker, i)); }
//alert('Vérification données reçues '+item.Titre_lieu+' -- '+item.Url_lieu+ ' -- '+item.LatLng_lieu);
}
});
}
});
}
initialiser() ;
////////////////////////////////////////////
return false;
} |