//
function printMap() {
if ( document.forms.add_form.poi_type.selectedIndex > 0 ) {
var center = map.getCenter();
var mapType = map.getCurrentMapType();
var mapBounds = escape(map.getBoundsLatLng());
// getZoom seems to return the inverse of the zoom
var mapCurrentZoom = 17 - map.getZoom();
var mapSize = map.getSize();
var page = document.getElementById('page').value;
var popwindow = '';
popwindow = window.open('http://www.gonmad.co.uk/satnav/printMap.php?page='+page+'&mWidth='+mapSize.width+'&mHeight='+mapSize.height+'&mZoom='+mapCurrentZoom+'&cLat='+center.lat()+'&cLng='+center.lng()+'&mapBounds='+mapBounds+'&zoom=&poi_type='+document.forms.add_form.poi_type[document.forms.add_form.poi_type.selectedIndex].value,'popwindow','Width=640, Height=620,resizable,scrollbars');
popwindow.focus();
} else {
alert("You must select a PoI type before printing a map.");
}
return(false);
}
//
function screenWidth() {
if(navigator.appName == "Netscape"){
var windowwidth = window.innerWidth;
}else if(navigator.appName == "Microsoft Internet Explorer"){
var windowwidth = document.body.clientWidth;
}else{
var windowwidth = 500;
}
return windowwidth;
}
function screenHeight() {
if(navigator.appName == "Netscape"){
var windowheight = window.innerHeight;
}else if(navigator.appName == "Microsoft Internet Explorer"){
var windowheight = document.body.clientHeight;
}else{
var windowwidth = 550;
}
return windowheight;
}
function setMapSize() {
var newWidth = screenWidth();
var newHeight = screenHeight();
newWidth = newWidth - 460;
if(newWidth < 450) { // stop bold in editor with >
newWidth = 450;
}
newWidth = newWidth + "px";
newHeight = newHeight - 70;
newHeight = newHeight + "px";
// document.getElementById('map').style.height = newHeight;
document.getElementById('map').style.width = newWidth;
// map.checkResize() ;
}
// Initialise the map
function load_map() {
// Load the map
if (!map) {
map = new GMap(document.getElementById("map"));
// center the map and set wide on UK
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.addControl(new GOverviewMapControl());
map.enableDoubleClickZoom();
map.enableContinuousZoom();
// map.setMapType(G_HYBRID_TYPE);
map.setMapType(G_HYBRID_MAP);
map.centerAndZoom(new GPoint(-2.05888, 53.64455), 12); // params (e/w,n/s,zoom)
}
// Add the listener that adds the marker and reads the lat/long info
// ??? Is this listener needed or is it this that causes the JS errors ???
// GEvent.addListener(map, 'click', function(overlay, point) {
// Set lat and long in form
// document.getElementById('latitude').value = point.y;
// document.getElementById('longitude').value = point.x;
// document.getElementById('edit_latitude').value = point.y;
// document.getElementById('edit_longitude').value = point.x;
// });
GEvent.addListener(map, 'zoomend', function(oldLevel, newLevel) {
oldLevel = 17 - oldLevel;
newLevel = 17 - newLevel;
// alert("zoomend triggered. old level=" + oldLevel + ", new level=" + newLevel);
if ( ( oldLevel >= iconSizeUpperZoomThresh && newLevel < iconSizeUpperZoomThresh ) ||
( oldLevel < iconSizeUpperZoomThresh && newLevel >= iconSizeUpperZoomThresh ) ||
( oldLevel >= iconSizeLowerZoomThresh && newLevel < iconSizeLowerZoomThresh ) ||
( oldLevel < iconSizeLowerZoomThresh && newLevel >= iconSizeLowerZoomThresh ) ){
// zoom level has crossed a threshold for icon size
// alert("zoom level has crossed a threshold for icon size. old level=" + oldLevel + ", new level=" + newLevel);
type_change(); // sets and loads the new icon size!
display_current_pois();
}
});
marker = new GMarker(map.getCenter(), {draggable: true});
marker.enableDragging();
// When the marker is moved, center the map on this point
// (which in turn updates the form)
GEvent.addListener(marker, "dragend", function() {
map.panTo(marker.getPoint());
});
map.addOverlay(marker);
// When the map is moved, update the form and move the marker
GEvent.addListener(map, "moveend", function() {
var center = map.getCenter();
document.getElementById("latitude").value = center.lat();
document.getElementById("longitude").value = center.lng();
document.getElementById("edit_latitude").value = center.lat();
document.getElementById("edit_longitude").value = center.lng();
marker.setPoint(center);
});
}
// Called whenever the File type drop down selection changes
function file_type_change() {
// Change the button type that gens the file
if ( document.forms.add_form.file_type.options[document.forms.add_form.file_type.selectedIndex].value == "att" ) {
document.getElementById('addToTomTomButton').style.visibility='visible';
document.getElementById('addToTomTomButton').style.display='block';
document.getElementById('genFileButton').style.visibility='hidden';
document.getElementById('genFileButton').style.display='none';
} else {
document.getElementById('genFileButton').style.visibility='visible';
document.getElementById('genFileButton').style.display='block';
document.getElementById('addToTomTomButton').style.visibility='hidden';
document.getElementById('addToTomTomButton').style.display='none';
}
// Disable the region selector if file type is add to tomtom (add to tomtom requires all pois)
if ( document.forms.add_form.file_type.options[document.forms.add_form.file_type.selectedIndex].value == "att" ) {
document.getElementById('fixed_region').style.visibility='visible';
document.getElementById('fixed_region').style.display='block';
document.getElementById('selectable_region').style.visibility='hidden';
document.getElementById('selectable_region').style.display='none';
} else {
document.getElementById('selectable_region').style.visibility='visible';
document.getElementById('selectable_region').style.display='block';
document.getElementById('fixed_region').style.visibility='hidden';
document.getElementById('fixed_region').style.display='none';
}
}
// Called whenever the PoI type drop down selection changes
function type_change() {
var start_tag = "";
var end_tag = "";
//alert("into type change");
switch (document.forms.add_form.poi_type[document.forms.add_form.poi_type.selectedIndex].value) {
case "":
document.getElementById('descr_descr').innerHTML = start_tag + end_tag;
active_poi_type = "";
document.getElementById('bmp_icon').src = "satnav/bmp_blank.bmp";
document.getElementById('gif_icon').src = "satnav/gif_blank.gif";
document.getElementById('png_icon').src = "satnav/png_blank.png";
document.getElementById('filename').value = "";
break;
case "dis_park":
//alert("Please enter the number of disabled parking spaces at this location and a brief description of where they are.
e.g. "High Street: 1 place outside WH Smiths", or
"Townsville Station: 2 spaces by station entrance"");
document.getElementById('descr_descr').innerHTML = start_tag + "Please enter the number of disabled parking spaces at this location and a brief description of where they are.
e.g. "High Street: 1 place outside WH Smiths", or
"Townsville Station: 2 spaces by station entrance"" + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Please enter the number of disabled parking spaces at this location and a brief description of where they are.
e.g. "High Street: 1 place outside WH Smiths", or
"Townsville Station: 2 spaces by station entrance"" + end_tag;
active_icon = dis_park_icon;
document.getElementById('phone_number_entry_add').style.visibility='hidden';
document.getElementById('phone_number_entry_add').style.display='none';
document.getElementById('phone_number_entry_cur').style.visibility='hidden';
document.getElementById('phone_number_entry_cur').style.display='none';
document.getElementById('phone_number_entry_edit').style.visibility='hidden';
document.getElementById('phone_number_entry_edit').style.display='none';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = dis_park_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_dis_park_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_dis_park_icon;
}
active_poi_type = "dis_park";
// sm_active_icon = sm_dis_park_icon;
// tiny_active_icon = tiny_dis_park_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/Disabled_Parking_Places.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/disabled_parking.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/disabled_parking.png";
document.getElementById('filename').value = "Disabled_Parking_Places";
break;
case "radar_key":
//alert("Please enter a brief description of the facility.
e.g. "Towsnville Station: Accessible toilet on platform 10"");
document.getElementById('descr_descr').innerHTML = start_tag + "Please enter a brief description of the facility.
e.g. "Towsnville Station: Accessible toilet on platform 10"" + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Please enter a brief description of the facility.
e.g. "Towsnville Station: Accessible toilet on platform 10"" + end_tag;
active_icon = radar_key_icon;
document.getElementById('phone_number_entry_add').style.visibility='hidden';
document.getElementById('phone_number_entry_add').style.display='none';
document.getElementById('phone_number_entry_cur').style.visibility='hidden';
document.getElementById('phone_number_entry_cur').style.display='none';
document.getElementById('phone_number_entry_edit').style.visibility='hidden';
document.getElementById('phone_number_entry_edit').style.display='none';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = radar_key_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_radar_key_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_radar_key_icon;
}
active_poi_type = "radar_key";
// sm_active_icon = sm_radar_key_icon;
// tiny_active_icon = tiny_radar_key_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/Radar_Key_Toilets.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/radar_toilets.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/radar_toilets.png";
document.getElementById('filename').value = "Radar_Key_Toilets";
break;
case "shopmobility":
//alert("Please enter the town/city and location of the Shopmobility facility.
e.g. "Townsville: Shoparama Shopping Center, Multistory car park"");
document.getElementById('descr_descr').innerHTML = start_tag + "Please enter the town/city and location of the Shopmobility facility.
e.g. "Townsville: Shoparama Shopping Center, Multistory car park"" + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Please enter the town/city and location of the Shopmobility facility.
e.g. "Townsville: Shoparama Shopping Center, Multistory car park"" + end_tag;
active_icon = shopmobility_icon;
document.getElementById('phone_number_entry_add').style.visibility='visible';
document.getElementById('phone_number_entry_add').style.display='block';
document.getElementById('phone_number_entry_cur').style.visibility='visible';
document.getElementById('phone_number_entry_cur').style.display='block';
document.getElementById('phone_number_entry_edit').style.visibility='visible';
document.getElementById('phone_number_entry_edit').style.display='block';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = shopmobility_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_shopmobility_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_shopmobility_icon;
}
active_poi_type = "shopmobility";
// sm_active_icon = sm_shopmobility_icon;
// tiny_active_icon = tiny_shopmobility_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/Shopmobility_Centre.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/shopmobility.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/shopmobility.png";
document.getElementById('filename').value = "Shopmobility_Centre";
break;
case "mway_servs":
//alert("Enter the name of the service station and the facilities/shops there.");
document.getElementById('descr_descr').innerHTML = start_tag + "Enter the name of the service station and the facilities/shops there." + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Enter the name of the service station and the facilities/shops there." + end_tag;
active_icon = mway_servs_icon;
document.getElementById('phone_number_entry_add').style.visibility='visible';
document.getElementById('phone_number_entry_add').style.display='block';
document.getElementById('phone_number_entry_cur').style.visibility='visible';
document.getElementById('phone_number_entry_cur').style.display='block';
document.getElementById('phone_number_entry_edit').style.visibility='visible';
document.getElementById('phone_number_entry_edit').style.display='block';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = mway_servs_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_mway_servs_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_mway_servs_icon;
}
active_poi_type = "mway_servs";
// sm_active_icon = sm_mway_servs_icon;
// tiny_active_icon = tiny_mway_servs_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/Motorway_Services.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/motorway_services.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/motorway_services.png";
document.getElementById('filename').value = "Motorway_Services";
break;
case "pubs_and_bars":
//alert("Please enter the name of the pub/bar and a brief description.
e.g. "The Horse and Groom: Quiet country pub with typical pub grub and real ales."");
document.getElementById('descr_descr').innerHTML = start_tag + "Please enter the name of the pub/bar and a brief description.
e.g. "The Horse and Groom: Quiet country pub with typical pub grub and real ales."" + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Please enter the name of the pub/bar and a brief description.
e.g. "The Horse and Groom: Quiet country pub with typical pub grub and real ales."" + end_tag;
active_icon = pubs_and_bars_icon;
document.getElementById('phone_number_entry_add').style.visibility='visible';
document.getElementById('phone_number_entry_add').style.display='block';
document.getElementById('phone_number_entry_cur').style.visibility='visible';
document.getElementById('phone_number_entry_cur').style.display='block';
document.getElementById('phone_number_entry_edit').style.visibility='visible';
document.getElementById('phone_number_entry_edit').style.display='block';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = pubs_and_bars_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_pubs_and_bars_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_pubs_and_bars_icon;
}
active_poi_type = "pubs_and_bars";
// sm_active_icon = sm_pubs_and_bars_icon;
// tiny_active_icon = tiny_pubs_and_bars_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/Pub_or_Bar.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/pubs_and_bars.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/pubs_and_bars.png";
document.getElementById('filename').value = "Pub_or_Bar";
break;
case "horseracing":
//alert("Please enter name of race course.");
document.getElementById('descr_descr').innerHTML = start_tag + "Please enter name of race course." + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Please enter name of race course." + end_tag;
active_icon = horseracing_icon;
document.getElementById('phone_number_entry_add').style.visibility='visible';
document.getElementById('phone_number_entry_add').style.display='block';
document.getElementById('phone_number_entry_cur').style.visibility='visible';
document.getElementById('phone_number_entry_cur').style.display='block';
document.getElementById('phone_number_entry_edit').style.visibility='visible';
document.getElementById('phone_number_entry_edit').style.display='block';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = horseracing_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_horseracing_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_horseracing_icon;
}
active_poi_type = "horseracing";
// sm_active_icon = sm_horseracing_icon;
// tiny_active_icon = tiny_horseracing_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/Horseracing_course.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/Horseracing_course.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/Horseracing_course.png";
document.getElementById('filename').value = "Horseracing_course";
break;
case "ga_airfield":
//alert("Please enter name of airfield followed by ICAO identifier in brackets ().
e.g. Carlisle (EGNC)");
document.getElementById('descr_descr').innerHTML = start_tag + "Please enter name of airfield followed by ICAO identifier in brackets ().
e.g. Carlisle (EGNC)" + end_tag;
document.getElementById('edit_descr_descr').innerHTML = start_tag + "Please enter name of airfield followed by ICAO identifier in brackets ().
e.g. Carlisle (EGNC)" + end_tag;
active_icon = ga_airfield_icon;
document.getElementById('phone_number_entry_add').style.visibility='visible';
document.getElementById('phone_number_entry_add').style.display='block';
document.getElementById('phone_number_entry_cur').style.visibility='visible';
document.getElementById('phone_number_entry_cur').style.display='block';
document.getElementById('phone_number_entry_edit').style.visibility='visible';
document.getElementById('phone_number_entry_edit').style.display='block';
var zoomLevel = 17 - map.getZoom();
if ( zoomLevel < iconSizeLowerZoomThresh ) { // correct editor display with >
// alert("big icon in type change (zoom level = " + zoomLevel + ")");
active_icon = ga_airfield_icon;
} else if ( zoomLevel >= iconSizeLowerZoomThresh && zoomLevel < iconSizeUpperZoomThresh ) { // correct editor display with >
// alert("small icon in type change (zoom level = " + zoomLevel + ")");
active_icon = sm_ga_airfield_icon;
} else if ( zoomLevel >= iconSizeUpperZoomThresh ) {
// alert("tiny icon in type change (zoom level = " + zoomLevel + ")");
active_icon = tiny_ga_airfield_icon;
}
active_poi_type = "ga_airfield";
// sm_active_icon = sm_ga_airfield_icon;
// tiny_active_icon = tiny_ga_airfield_icon;
document.getElementById('bmp_icon').src = "http://www.gonmad.co.uk/satnav/G_A_Airfield.bmp";
document.getElementById('gif_icon').src = "http://www.gonmad.co.uk/satnav/G_A_Airfield.gif";
document.getElementById('png_icon').src = "http://www.gonmad.co.uk/satnav/G_A_Airfield.png";
document.getElementById('filename').value = "G_A_Airfield";
break;
default:
document.getElementById('descr_descr').innerHTML = start_tag + end_tag;
active_poi_type = "";
document.getElementById('bmp_icon').src = "satnav/bmp_blank.bmp";
document.getElementById('gif_icon').src = "satnav/gif_blank.gif";
document.getElementById('png_icon').src = "satnav/png_blank.png";
document.getElementById('filename').value = "";
break;
}
}
// Create one of our markers at the given point.
function createMarker(point, icon) {
var new_marker = new GMarker(point, icon);
return new_marker;
}
// used by display_current_pois to add the marker
function add_existing_poi_marker(this_poi) {
poi_points_markers[this_poi] = createMarker(new GPoint(this_longitude, this_latitude), active_icon);
if ( this_poi_type == "dis_park" ) {
// include the phone number if valid for this poi_type... or if not empty?
if ( this_phone == "" ) {
poi_points_html[this_poi] = "
Disabled Parking
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Disabled Parking
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Radar Key Toilet
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Radar Key Toilet
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Shopmobility Centre
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Shopmobility Centre
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Motorway Service Station
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Motorway Service Station
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Pub or Bar
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Pub or Bar
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Horse Racing Course
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
Horse Racing Course
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
G.A. Airfield
" + this_descr + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
G.A. Airfield
" + this_descr + "
+" + this_phone + "
Longitude: " + poi_points_longs[this_poi] + "
Latitude: " + poi_points_lats[this_poi] + "
"; poi_points_html[this_poi] += "Zoom to this PoI"; poi_points_html[this_poi] += " | "; poi_points_html[this_poi] += "Edit this PoI"; poi_points_html[this_poi] += " | "; poi_points_html[this_poi] += "Delete this PoI"; poi_points_html[this_poi] += "
"; // Create a listener for the go marker click GEvent.addListener(poi_points_markers[this_poi], "click", function() { // only show the info window if below upper zoom threshold var zoomLevel = 17 - map.getZoom(); if ( zoomLevel < iconSizeUpperZoomThresh ) { // extra > for editor poi_points_markers[this_poi].openInfoWindowHtml(poi_points_html[this_poi]); } document.getElementById('latitude').value = poi_points_lats[this_poi]; document.getElementById('longitude').value = poi_points_longs[this_poi]; document.getElementById('descr').value = poi_points_descrs[this_poi]; document.getElementById('phone').value = poi_points_phones[this_poi]; document.getElementById('edit_latitude').value = poi_points_lats[this_poi]; document.getElementById('edit_longitude').value = poi_points_longs[this_poi]; document.getElementById('edit_descr').value = poi_points_descrs[this_poi]; document.getElementById('edit_phone').value = poi_points_phones[this_poi]; document.getElementById('cur_edit_latitude').value = poi_points_lats[this_poi]; document.getElementById('cur_edit_longitude').value = poi_points_longs[this_poi]; document.getElementById('cur_edit_descr').value = poi_points_descrs[this_poi]; document.getElementById('cur_edit_phone').value = poi_points_phones[this_poi]; document.getElementById('del_latitude').value = poi_points_lats[this_poi]; document.getElementById('del_longitude').value = poi_points_longs[this_poi]; document.getElementById('del_descr').value = poi_points_descrs[this_poi]; }); map.addOverlay(poi_points_markers[this_poi]); } // display the PoIs for the current selected type function display_current_pois() { //alert("into display curren pois"); map.clearOverlays(); // Put the 'new point' marker back after the removal map.addOverlay(marker); if ( document.forms.add_form.poi_type.selectedIndex > 0 ) { var numb_pois = poi_points_lats.length; var this_poi = 0; for (this_poi=0 ; this_poi < numb_pois ; this_poi++ ) { this_latitude = poi_points_lats[this_poi]; this_longitude = poi_points_longs[this_poi]; this_descr = poi_points_descrs[this_poi]; this_phone = poi_points_phones[this_poi]; this_poi_type = poi_points_types[this_poi]; if ( this_poi_type == active_poi_type ) { add_existing_poi_marker(this_poi); } } } } // Used when adding a PoI. This func checks that all values are entered and then submits new PoI via AJAX function add_check_values() { if ( document.forms.add_form.poi_type.selectedIndex > 0 ) { if ( descrIsOK("add") == true ) { if ( map.getZoomLevel() > 0 ) { alert("STOP!\n\nYou should zoom the map to the maximum amount\nto ensure accurate positioning of your PoI before\nclicking the 'Add this PoI' button.\n\nSee the 'Help' tab on the main screen below if you are unsure of how to do that.") } else { if ( document.getElementById('latitude').value == "" || document.getElementById('longitude').value == "" || document.getElementById('descr').value == "" ) { alert("You must position the marker on the map\nto generate valid longitude, latitude\nand you must enter a description."); return false; // Check long and lat are within range for the region // } else if ( document.getElementById('latitude').value < 49.95 || document.getElementById('latitude').value > 60.8 || document.getElementById('longitude').value < -10.66 || document.getElementById('longitude').value > 1.77 ) { // alert("Point appears to be outside of the UK.\nOnly UK PoIs are accepted."); // return false; } else { ajaxAddPOI(); return false; } } } } else { alert("You must select a PoI type before trying to add a PoI."); } } // Check if description is within limits depending if phone number included function descrIsOK(checkType) { var maxLength = 63; var thisLength = 0; var overLength = 0; switch (document.forms.add_form.poi_type[document.forms.add_form.poi_type.selectedIndex].value) { case "": thisLength = 0; break; case "dis_park": if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length; } else { thisLength = document.forms.add_form.edit_descr.value.length; } break; case "radar_key": if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length; } else { thisLength = document.forms.add_form.edit_descr.value.length; } break; case "shopmobility": // descr + phone number + 2 for the space and chevron added in tomtom descriptions if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length + document.forms.add_form.phone.value.length + 2; } else { thisLength = document.forms.add_form.edit_descr.value.length + document.forms.add_form.edit_phone.value.length + 2; } break; case "mway_servs": // descr + phone number + 2 for the space and chevron added in tomtom descriptions if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length + document.forms.add_form.phone.value.length + 2; } else { thisLength = document.forms.add_form.edit_descr.value.length + document.forms.add_form.edit_phone.value.length + 2; } break; case "pubs_and_bars": // descr + phone number + 2 for the space and chevron added in tomtom descriptions if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length + document.forms.add_form.phone.value.length + 2; } else { thisLength = document.forms.add_form.edit_descr.value.length + document.forms.add_form.edit_phone.value.length + 2; } break; case "horseracing": // descr + phone number + 2 for the space and chevron added in tomtom descriptions if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length + document.forms.add_form.phone.value.length + 2; } else { thisLength = document.forms.add_form.edit_descr.value.length + document.forms.add_form.edit_phone.value.length + 2; } break; case "ga_airfield": // descr + phone number + 2 for the space and chevron added in tomtom descriptions if ( checkType == "add" ) { thisLength = document.forms.add_form.descr.value.length + document.forms.add_form.phone.value.length + 2; } else { thisLength = document.forms.add_form.edit_descr.value.length + document.forms.add_form.edit_phone.value.length + 2; } break; default: thisLength = 0; break; } //alert("combined length = " + thisLength); if ( thisLength <= maxLength ) { // extra > for editor return true; } else { overLength = thisLength - maxLength; alert("Description is too long, please shorten by " + overLength + " character(s)."); return false; } } // Used when updating a PoI. This func checks that all values are entered and then submits new PoI via AJAX function update_check_values() { if ( document.forms.add_form.poi_type.selectedIndex > 0 ) { if ( descrIsOK("edit") == true ) { if ( map.getZoomLevel() > 0 ) { alert("STOP!\n\nYou should zoom the map to the maximum amount\nto ensure accurate positioning of your PoI before\nclicking the 'Update this PoI' button.\n\nSee the 'Help' tab on the main screen below if you are unsure of how to do that.") } else { if ( document.getElementById('edit_latitude').value == "" || document.getElementById('edit_longitude').value == "" || document.getElementById('edit_descr').value == "" ) { alert("You must position the marker on the map\nto generate valid longitude, latitude\nand you must enter a description."); return false; // Check long and lat are within range for the region // } else if ( document.getElementById('edit_latitude').value < 49.95 || document.getElementById('edit_latitude').value > 60.8 || document.getElementById('edit_longitude').value < -10.66 || document.getElementById('edit_longitude').value > 1.77 ) { // alert("New position appears to be outside of the UK.\nOnly UK PoIs are accepted."); // return false; } else { ajaxUpdatePOI(); return false; } } } } else { alert("You must select a PoI type before trying to edit a PoI."); } } // Used when deleting a PoI. This func checks that all values are entered and then submits new PoI via AJAX function del_check_values() { if ( document.forms.add_form.poi_type.selectedIndex > 0 ) { if ( document.getElementById('del_latitude').value == "" || document.getElementById('del_longitude').value == "" ) { alert("You must click and exiting PoI to retrieve it's longitude\nand latitude into the delete tab to delete a PoI."); return false; } else { ajaxDeletePOI(); return false; } } else { alert("You must select a PoI type before trying to delete a PoI."); } } // Create an AJAX object for use in other AJAX functions function createAJAX() { var phpRequest = null; if (window.XMLHttpRequest) { phpRequest = new XMLHttpRequest(); } if (window.ActiveXObject) { phpRequest = new ActiveXObject("Microsoft.XMLHTTP"); } return(phpRequest); } // Add the new PoI without reloading by using an AJAX request function ajaxAddPOI() { var phpRequest = createAJAX(); var add_type = document.forms.add_form.poi_type.options[document.forms.add_form.poi_type.selectedIndex].value; var add_latitude = document.getElementById('latitude').value; var add_longitude = document.getElementById('longitude').value; var add_descr = document.getElementById('descr').value; var add_phone = document.getElementById('phone').value; var currentTime = new Date(); document.getElementById('add_button').disabled = true; document.getElementById('status_text').innerHTML = "Adding PoI..."; var add_url = "http://www.gonmad.co.uk/satnav/add_poi_for_ajax.php?poi_type=" + add_type + "&latitude=" + add_latitude + "&longitude=" + add_longitude + "&descr=" + add_descr + "&phone=" + add_phone + "&rnd=" + currentTime.getMilliseconds(); phpRequest.onreadystatechange = function() { if (phpRequest.readyState == 4) { if (phpRequest.status == 200) { document.getElementById('status_text').innerHTML = "" + phpRequest.responseText + ""; ajaxLoadCurrentPois(phpRequest.responseText); display_current_pois(); document.getElementById('add_button').disabled = false; } } } phpRequest.open("GET", add_url, true); phpRequest.send(null); } // Update a PoI without reloading by using an AJAX request function ajaxUpdatePOI() { //alert("into ajaxUpdatePOI"); var phpRequest = createAJAX(); var update_type = document.forms.add_form.poi_type.options[document.forms.add_form.poi_type.selectedIndex].value; var update_latitude = document.getElementById('edit_latitude').value; var update_longitude = document.getElementById('edit_longitude').value; var update_descr = document.getElementById('edit_descr').value; var update_phone = document.getElementById('edit_phone').value; var update_cur_latitude = document.getElementById('cur_edit_latitude').value; var update_cur_longitude = document.getElementById('cur_edit_longitude').value; var update_cur_descr = document.getElementById('cur_edit_descr').value; var currentTime = new Date(); document.getElementById('edit_button').disabled = true; document.getElementById('status_text').innerHTML = "Updating PoI..."; var update_url = "http://www.gonmad.co.uk/satnav/update_poi_for_ajax.php?poi_type=" + update_type + "&cur_latitude=" + update_cur_latitude + "&cur_longitude=" + update_cur_longitude + "&cur_descr=" + update_cur_descr + "&latitude=" + update_latitude + "&longitude=" + update_longitude + "&descr=" + update_descr + "&phone=" + update_phone + "&rnd=" + currentTime.getMilliseconds(); // alert("update url = " + update_url); // window.open(update_url); phpRequest.onreadystatechange = function() { if (phpRequest.readyState == 4) { if (phpRequest.status == 200) { document.getElementById('status_text').innerHTML = "" + phpRequest.responseText + ""; ajaxLoadCurrentPois(phpRequest.responseText); display_current_pois(); document.getElementById('edit_button').disabled = false; } } } phpRequest.open("GET", update_url, true); phpRequest.send(null); } // Mark a PoI for deletion without reloading by using an AJAX request function ajaxDeletePOI() { var phpRequest = createAJAX(); var del_type = document.forms.add_form.poi_type.options[document.forms.add_form.poi_type.selectedIndex].value; var del_latitude = document.getElementById('del_latitude').value; var del_longitude = document.getElementById('del_longitude').value; var del_descr = document.getElementById('del_descr').value; var currentTime = new Date(); document.getElementById('del_button').disabled = true; document.getElementById('status_text').innerHTML = "Marking PoI for deletion..."; var del_url = "http://www.gonmad.co.uk/satnav/del_poi_for_ajax.php?poi_type=" + del_type + "&latitude=" + del_latitude + "&longitude=" + del_longitude + "&descr=" + del_descr + "&rnd=" + currentTime.getMilliseconds(); //window.open(del_url); phpRequest.onreadystatechange = function() { if (phpRequest.readyState == 4) { if (phpRequest.status == 200) { document.getElementById('status_text').innerHTML = "" + phpRequest.responseText + ""; ajaxLoadCurrentPois(phpRequest.responseText); display_current_pois(); document.getElementById('del_button').disabled = false; } } } phpRequest.open("GET", del_url, true); phpRequest.send(null); } // Load the existing PoIs into the PoI arrays from dbase via AJAX request on the fly function ajaxLoadCurrentPois(prepend_text) { var phpRequest = createAJAX(); var get_type = document.forms.add_form.poi_type.options[document.forms.add_form.poi_type.selectedIndex].value; var doing_latitude; var doing_longitude; var doing_descr; var doing_type; var count; var records_array = new Array(); var currentTime = new Date(); var get_url = "http://www.gonmad.co.uk/satnav/get_all_pois_for_ajax.php?poi_type=" + get_type + "&rnd=" + currentTime.getMilliseconds(); document.getElementById('status_text').innerHTML = "Loading PoIs"; phpRequest.onreadystatechange = function() { if (phpRequest.readyState == 4) { if (phpRequest.status == 200) { records_array = phpRequest.responseText.split("\n"); for(count=0;count