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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
var map = null;
var geocoder = null;
var TousMesMarqueurs = [];
var save = null;
var Obj=null;
function load()
{
var baseIcon = new GIcon();
baseIcon.iconSize=new GSize(40,40);
baseIcon.shadowSize=new GSize(0,0);
baseIcon.iconAnchor=new GPoint(3,38);
baseIcon.infoWindowAnchor=new GPoint(29,1);
var Zope = new GIcon(baseIcon, 'image/puce_punaise_blue.png', null, '');
var CPS = new GIcon(baseIcon, 'image/puce_punaise_yellow.png', null, '');
var Java = new GIcon(baseIcon, 'image/puce_punaise_red.png', null, '');
var Alfresco = new GIcon(baseIcon, 'image/puce_punaise_black.png', null, '');
var Linux = new GIcon(baseIcon, 'image/puce_punaise_green.png', null, '');
var MySQL = new GIcon(baseIcon, 'image/puce_punaise_orange.png', null, '');
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(43.233,5.398), 15);
geocoder = new GClientGeocoder();
}
var ToutesLesBalisesInput = document.getElementsByTagName('input');
if(ToutesLesBalisesInput != null){
for(var i = 0; i < ToutesLesBalisesInput.length; i++){
if(ToutesLesBalisesInput[i].type == 'checkbox'){
ToutesLesBalisesInput[i].onclick=function(){EnvoiLoisir(this);}
}
}
}
function EnvoiLoisir(val){
if(val == null){return;}
var loisirselec=val.value;
if(val.checked==true){
if(save != val.value && save !=null){
Obj.checked=false;
GDownloadUrl('data.xml', function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName('marker');
for (var i = 0; i < markers.length; i++) {
var type = markers[i].getAttribute('type');
var typeTab = eval(type);
for (var j = 0; j < typeTab.length; j++) {
if(typeTab[j].title == save){ <!-- ... les marqueurs correspondant à la catégorie ... -->
map.removeOverlay(TousMesMarqueurs[i]);<!-- ... sont masqués -->
}
}
}
});
}
GDownloadUrl('data.xml', function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName('marker');
for (var i = 0; i < markers.length; i++) {
var type = markers[i].getAttribute('type');
var typeTab = eval(type);
for (var j = 0; j < typeTab.length; j++) {
if(typeTab[j].title == loisirselec ){
var point = new GLatLng(parseFloat(markers[i].getAttribute('lat')), parseFloat(markers[i].getAttribute('lng')));
var nom = markers[i].getAttribute('nom');
var prenom = markers[i].getAttribute('prenom');
var image = markers[i].getAttribute('image');
var type = markers[i].getAttribute('type');
var marker = CreationDuMarqueur(point, nom, prenom, image, typeTab[j], i);
//MODDIFICATION N°2 ICI
map.addOverlay(marker);
map.setCenter(point, 15);
}
}
}
});
}
if(val.checked==false){ <!-- Si la case est décochée ... -->
GDownloadUrl('data.xml', function(data) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName('marker');
for (var i = 0; i < markers.length; i++) {
var type = markers[i].getAttribute('type');
var typeTab = eval(type);
for (var j = 0; j < typeTab.length; j++) {
if(typeTab[j].title == loisirselec){ <!-- ... les marqueurs correspondant à la catégorie ... -->
map.removeOverlay(TousMesMarqueurs[i]);<!-- ... sont masqués -->
}
}
}
});
}
save = val.value;
Obj = val;
}
function CreationDuMarqueur(point, nom, prenom, image, type, i) {
if(type.title=='Zope'){var icone = Zope;}
if(type.title=='CPS'){var icone = CPS;}
if(type.title=='Java'){var icone = Java;}
if(type.title=='Alfresco'){var icone = Alfresco;}
if(type.title=='Linux'){var icone = Linux;}
if(type.title=='MySQL'){var icone = MySQL;}
var marker = new GMarker(point,icone);
TousMesMarqueurs[i]=marker;
GEvent.addListener(marker, 'click', function() { <!-- En cas de click sur le marqueur ... -->
var imgs = '';
for(var i=0; i < type.star; i++) {
imgs += '<img src="image/X.gif" height="23" width="23">';
}
marker.openInfoWindowHtml('<b>' + nom+ ' ' + prenom + '</b><br/>' + image + '<br/>' + '<br/>' + type.title +'<br/>'+ imgs);
});
return marker;
}
}
function showAddress(address) {
if (geocoder) {
geocoder.getLatLng(address,function(point) {
if (!point) {
alert(address + " not found");
}
else {
map.setCenter(point, 15);
var marker = new GMarker(point);
map.addOverlay(marker);
}
});
}
} |
Partager