var addrpnt ; var geocoder ; var address ; var icon ; var map ; var container; var opacity = 0.4; var circle; var centerMarker; var circleUnits; var circleRadius; var icon_mbr = new GIcon(); icon_mbr.image = "URL/mbr_on.png"; icon_mbr.shadow = "URL/mbr_shad.png"; icon_mbr.iconSize = new GSize(28, 32); icon_mbr.shadowSize = new GSize(28, 32); icon_mbr.iconAnchor = new GPoint(14, 32); var icon_phot = new GIcon(); icon_phot.image = "URL/phot_on.png"; icon_phot.shadow = "URL/phot_shad.png"; icon_phot.iconSize = new GSize(28, 32); icon_phot.shadowSize = new GSize(28, 32); icon_phot.iconAnchor = new GPoint(14, 32); var icon_vid = new GIcon(); icon_vid.image = "URL/cam_on.png"; icon_vid.shadow = "URL/cam_shad.png"; icon_vid.iconSize = new GSize(28, 32); icon_vid.shadowSize = new GSize(28, 32); icon_vid.iconAnchor = new GPoint(14, 32); var icon_event = new GIcon(); icon_event.image = "URL/event_on.png"; icon_event.shadow = "URL/event_shad.png"; icon_event.iconSize = new GSize(28, 32); icon_event.shadowSize = new GSize(28, 32); icon_event.iconAnchor = new GPoint(14, 32); var icon_actu = new GIcon(); icon_actu.image = "URL/actu_on.png"; icon_actu.shadow = "URL/actu_shad.png"; icon_actu.iconSize = new GSize(28, 32); icon_actu.shadowSize = new GSize(28, 32); icon_actu.iconAnchor = new GPoint(14, 32); var icon_info = new GIcon(); icon_info.image = "URL/info_on.png"; icon_info.shadow = "URL/info_off.png"; icon_info.iconSize = new GSize(28, 32); icon_info.shadowSize = new GSize(28, 32); icon_info.iconAnchor = new GPoint(14, 32); var icon_home = new GIcon(); icon_home.image = "URL/home_on.png"; icon_home.shadow = "URL/home_off.png"; icon_home.iconSize = new GSize(28, 32); icon_home.shadowSize = new GSize(28, 32); icon_home.iconAnchor = new GPoint(14, 32); var icon_idee = new GIcon(); icon_idee.image = "URL/idee_on.png"; icon_idee.shadow = "URL/idee_off.png"; icon_idee.iconSize = new GSize(28, 32); icon_idee.shadowSize = new GSize(28, 32); icon_idee.iconAnchor = new GPoint(14, 32); var icon_travaux = new GIcon(); icon_travaux.image = "URL/travaux_on.png"; icon_travaux.shadow = "URL/travaux_off.png"; icon_travaux.iconSize = new GSize(28, 32); icon_travaux.shadowSize = new GSize(28, 32); icon_travaux.iconAnchor = new GPoint(14, 32); var customIcons = []; customIcons["users"] = icon_mbr; customIcons["picture"] = icon_phot; customIcons["video"] = icon_vid; customIcons["event"] = icon_event; customIcons["news"] = icon_actu; customIcons["info"] = icon_info; customIcons["home"] = icon_home; customIcons["idee"] = icon_idee; customIcons["travaux"] = icon_travaux; function loadmembers(a) { var markerGroups = { "users": [], "picture": [], "video": [], "event": [], "info": [], "home": [], "idee": [], "travaux": []}; var file2 = String(a); var request = GXmlHttp.create(); request.open("GET", "URL/markers.php?op=maj"+ file2 +"", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = request.responseXML; parseXML(xmlDoc); } } request.send(null); } function parseXML(xmlDoc) { var markers = xmlDoc.documentElement.getElementsByTagName("poi"); if (circle) { var bounds = circle.getBounds(); } else { var bounds = map.getBounds(); } for (var i = 0; i < markers.length; i++) { var name = markers[i].getAttribute("name"); var label = markers[i].getAttribute("label"); var name = markers[i].getAttribute("label"); var address = markers[i].getAttribute("address"); var type = markers[i].getAttribute("type"); var html = markers[i].getAttribute("type"); var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng"))); var marker = createMarker(point, name, label, address, type, html); if (bounds.contains(point) == true) { map.addOverlay(marker); } } } function createMarker(point, name, label, address, type, html) { var marker = new LabeledMarker(point, {icon: customIcons[type]}); markerGroups[type].push(marker); GEvent.addListener(marker, 'click', function() { sendajax('case=maj'+type+'&ID='+name+'','widget_ajax.php','det'); }); return marker; } function majcarte() { if (document.Register.radiusInput.value>0) { drawCircle(); } else { map.clearOverlays();loadmembers('&typ=' + document.Register.tip.value+ '&categ=' + document.Register.cat.value); } } function majcarte2() { if (document.Register.radiusInput.value>0) { drawCircle(); } else { loadmembers('&typ=' + document.Register.tip.value+ '&categ=' + document.Register.cat.value); } } function hideGroup(type) { for (var i = 0; i < markerGroups[type].length; i++) { map.removeOverlay(markerGroups[type][i]); } } function drawCircle() { var oRadius = document.getElementById('radiusInput'); if (oRadius.value.match(/[^\d.]/)) { alert("Don't be silly. Enter a number for radius"); return; } if (oRadius.value > 9999) { } circleRadius = oRadius.value; circleUnits = 'KM'; doDrawCircle(); if (markerGroups['picture'].length > 0 ) { hideGroup('picture'); } if (markerGroups['video'].length > 0 ) { hideGroup('video'); } if (markerGroups['event'].length > 0 ) { hideGroup('event'); } if (markerGroups['users'].length > 0 ) { hideGroup('users'); } if (markerGroups['news'].length > 0 ) { hideGroup('news'); } if (markerGroups['home'].length > 0 ) { hideGroup('home'); } if (markerGroups['travaux'].length > 0 ) { hideGroup('travaux'); } if (markerGroups['idee'].length > 0 ) { hideGroup('idee'); } if (markerGroups['info'].length > 0 ) { hideGroup('info'); } loadmembers('&typ=' + document.getElementById('tip').value+ '&categ=' + document.getElementById('cat').value); } function doDrawCircle(){ if (circle) { map.removeOverlay(circle); } if (centerMarker) { map.setCenter(centerMarker.getLatLng()) } else { centerMarker = new GMarker(map.getCenter(),{draggable:true}); GEvent.addListener(centerMarker,'dragend',drawCircle) map.setCenter(centerMarker.getLatLng()); map.addOverlay(centerMarker); } var center = map.getCenter(); var bounds = new GLatLngBounds(); var circlePoints = Array(); with (Math) { var d = circleRadius/6378.8; var lat1 = (PI/180)* center.lat(); // radians var lng1 = (PI/180)* center.lng(); // radians for (var a = 0 ; a < 361 ; a++ ) { var tc = (PI/180)*a; var y = asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc)); var dlng = atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y)); var x = ((lng1-dlng+PI) % (2*PI)) - PI ; // MOD function var point = new GLatLng(parseFloat(y*(180/PI)),parseFloat(x*(180/PI))); circlePoints.push(point); bounds.extend(point); } if (d < 1.5678565720686044) { circle = new GPolygon(circlePoints, '#9ecff3', 2, 1, '#9ecff3', 0.25); } map.addOverlay(circle); } }