 var icons = new Array(); var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/map_tube_station_grey.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_grey"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/map_tube_station.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_colored"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/tube/1_grey.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_1"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/tube/2_grey.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_2"] = icon; var icon = new GIcon(); icon.image = "./images/icons/tube/3_grey.gif"; icon.shadow = "./images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_3"] = icon; var icon = new GIcon(); icon.image = "./images/icons/tube/4_grey.gif"; icon.shadow = "./images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_4"] = icon; var icon = new GIcon(); icon.image = "./images/icons/tube/5_grey.gif"; icon.shadow = "./images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_5"] = icon; var icon = new GIcon(); icon.image = "./images/icons/tube/7_grey.gif"; icon.shadow = "./images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_7"] = icon; var icon = new GIcon(); icon.image = "./images/icons/tube/8_grey.gif"; icon.shadow = "./images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_8"] = icon; var icon = new GIcon(); icon.image = "./images/icons/tube/9_grey.gif"; icon.shadow = "./images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_9"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/tube/10_grey.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_10"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/tube/11_grey.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_11"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/tube/12_grey.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(28, 28); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["landmark_12"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/map_hotel_not_selected_smal.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(20, 20); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(8, 16); icon.infoWindowAnchor = new GPoint(14, 14); icons["hotel_small"] = icon; var icon = new GIcon(); icon.image = "http://www.matchhotels.com/moplugin/images/icons/map_hotel_not_selected.gif"; icon.shadow = "http://www.matchhotels.com/moplugin/images/icons/trans_pix.gif"; icon.iconSize = new GSize(27, 27); icon.shadowSize = new GSize(1, 1); icon.iconAnchor = new GPoint(14, 27); icon.infoWindowAnchor = new GPoint(14, 14); icons["hotel_big"] = icon; /* ===================================================================================================== ===================================================================================================== */ var map_center_lat = "51.5"; /*default values*/ var map_center_long = "-0.1166"; /*default values*/ var map_zoom_level = 12; /*default values*/ var city_min_zoom = 1; var city_max_zoom = 7; var landmark_min_zoom = 5; var landmark_max_zoom = 17; var hotel_min_zoom = 10; var hotel_max_zoom = 17; var markers = new Array(); /*keep the marker objects for landmarks*/ var landmark_details = new Array(); /*keep the landmark details*/ var hotel_details = new Array(); /*keep the hotel details*/ var current_landmark_type_id = 1; var map_move_enabled = false; var map = new Object(); var labeled_marker_opts = { "icon": icon, "clickable": false, "draggable": false, "labelText": "", "labelOffset": new GSize(-14, -14) }; function load_map() { if (GBrowserIsCompatible()) { map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng( map_center_lat, map_center_long), map_zoom_level); map.addControl(new GSmallMapControl()); /*map.addControl(new GLargeMapControl());*/ map.addControl(new GMapTypeControl()); landmarkers_manager = new GMarkerManager(map, {trackMarkers: true}); hotels_manager = new GMarkerManager(map, {trackMarkers: true}); GEvent.addListener(map, "zoomend", function (oldLevel, newLevel) { if ( (oldLevel > newLevel) && (newLevel < (landmark_min_zoom )) && (newLevel > (landmark_min_zoom - 4))) { map.openInfoWindow(map.getCenter(), "zoom in to see more"); } } ); GEvent.addListener(map, "moveend", function() { /*this is to get other points on the map*/ maps_center = map.getCenter(); center_lat = maps_center.lat(); center_long = maps_center.lng(); try{ input_coord_lat = $('coord_lat'); input_coord_long = $('coord_long'); input_coord_lat.value = center_lat; input_coord_long.value = center_long; input_coord = $('coord_value'); input_coord.value = Math.round(center_lat*10000)/10000 + ', ' + Math.round(center_long*10000)/10000 } catch(e) { } if (hotels_manager.getMarkerCount() > 50) { return true; } if (!map_move_enabled) { return true; } /*alert("map loading");*/ show("map_loading"); map_bounds = map.getBounds(); sw = map_bounds.getSouthWest(); ne = map_bounds.getNorthEast(); min_lat = sw.lat(); max_lat = ne.lat(); min_long = sw.lng(); max_long = ne.lng(); landmark_id = document.search_form.landmark_name_selected.value; if (!landmark_id ) return; var url = "ajax.php"; var pars = 'action=landmark_map_moved&landmark_id='+ landmark_id +'&min_lat=' +min_lat+'&max_lat='+max_lat+'&min_long='+min_long+'&max_long='+max_long; var myAjax = new Ajax.Request( url, { method: 'get', parameters: pars, onComplete: add_json_markers, onException: hide("map_loading"), onSuccess: hide("map_loading") } ); }); } } /* ===================================================================================================== ===================================================================================================== */ function createLandMarker(point, number, type) { var marker = new GMarker(point, icons["landmark_"+type] ); GEvent.addListener(marker, "click", function() { try{ marker_open_info(number); } catch(err) { } }); GEvent.addListener(marker, "mouseover", function() { try{ marker_set_color_icon(number); } catch(err) { } }); GEvent.addListener(marker, "mouseout", function() { try{ marker_set_grey_icon(number); } catch(err) { } }); markers[number] = marker; return marker; } /* ===================================================================================================== ======================= HOMEPAGE EVENTS ============================================================= ===================================================================================================== */ function marker_open_info(number) { /*map.panTo( markers[number].getPoint() );*/ if (markers[number]) { name = landmark_details[number]["name"]; if (landmark_details[number]["address"]) { address = landmark_details[number]["address"]; } else { address = ''; } link = landmark_details[number]["link"]; markers[number].openInfoWindowHtml("<div class='landmark_overlay'><a href='"+link+"' class='txt_hotel_blue'><b>" + name + "</b></a><br>" + address + "</div>", ({maxWidth:'100'}) ); marker_set_color_icon(number); } } function marker_set_color_icon(number) { try { if (div = document.getElementById("land_"+number)) { div.style.textDecoration = "underline"; } if (markers[number]) { type = landmark_details[number]["type"]; markers[number].setImage("http://www.matchhotels.com/moplugin/images/icons/tube/"+type+".gif"); } } catch (err) { } } function marker_set_grey_icon(number) { try { if (div = document.getElementById("land_"+number)) { div.style.textDecoration = "none"; } if (markers[number]) { type = landmark_details[number]["type"]; markers[number].setImage("http://www.matchhotels.com/moplugin/images/icons/tube/"+type+"_grey.gif"); } } catch (err) { } } /* ===================================================================================================== ======================= LANDMARK PAGE EVENTS ======================================================== ===================================================================================================== */ function initialize_landmark_map() { var landmark = createLandMarker( new GLatLng( map_center_lat, map_center_long ), current_landmark_id, current_landmark_type_id); landmarkers_manager.addMarker(landmark, landmark_min_zoom, landmark_max_zoom); landmarkers_manager.refresh(); } function createLabeledMarker(point, number, icon, label) { opts = { "icon": icon, "clickable": false, "draggable": false, "labelText": label, "labelOffset": new GSize(-9, -22) /* width - if the number goes to zero, the number is placed at the right of the icon. height if the height goes towards zero, the number will be placed under the icon */ }; var marker = new LabeledMarker(point, opts); GEvent.addListener(marker, "click", function() { hotel_open_info(number); }); GEvent.addListener(marker, "mouseover", function() { hotel_set_selected_icon(number); }); GEvent.addListener(marker, "mouseout", function() { hotel_set_not_selected_icon(number); }); markers[number] = marker; return marker; } function hotel_open_info(hotel_id) { try{ if (markers[hotel_id]) { name = marker_details[hotel_id]["name"]; link = "#";/*marker_details[hotel_id]["link"];*/ onclick = "toggle_hotel_details("+hotel_id+"); return false;"; thumb_url = marker_details[hotel_id]["thumb_url"]; address = marker_details[hotel_id]["address"]; distance = marker_details[hotel_id]["distance"]; star_rating_img = marker_details[hotel_id]["star_rating_img"]; price = marker_details[hotel_id]["price"]; price_link = marker_details[hotel_id]["price_link"]; if (thumb_url) { image_td = '<td rowspan="4"><a href="'+link+'"><img width="70" border="0" src="'+thumb_url+'"></a></td><td rowspan="4" class="spacer" width="10">&nbsp;</td>'; } else { image_td = ''; } if (price == "") { best_price_td = ''; more_link_text = "more info"; } else { best_price_td = '<tr><td class="hotel_overlay_price"><div class="hotel_overlay_best_price"><b>Best price:</b> '+price+'&nbsp;</div><div class="hotel_overlay_supplier_link">'+price_link+'</div></td></tr>'; more_link_text = "more info and prices"; } if (distance == "") { distance = address; } markers[hotel_id].openInfoWindowHtml( '<table class="hotel_overlay" cellpadding="0" cellspacing="0">'+ '<tr><td class="hotel_overlay_name">'+name+'</td></tr>'+ '<tr><td class="hotel_overlay_address"><div class="hotel_overlay_stars">'+star_rating_img+'</div><div class="hotel_overlay_distance">'+distance+'</div></td></tr>'+ best_price_td + '<tr><td><a class="hotel_overlay_more_link" href="#" onclick="hotel_details_overlay('+hotel_id+'); return false;">'+more_link_text+'</a></td></tr>'+ '</table>'); /*markers[hotel_id].openInfoWindowHtml('Muie',opts);*/ hotel_set_selected_icon(hotel_id); } } catch(err) { } } function hotel_set_selected_icon(hotel_id) { try{ if (div = document.getElementById("hotel_"+hotel_id)) { div.style.backgroundColor = "#fff5de"; } } catch(err) { } try{ if (div = document.getElementById("hotel_details_"+hotel_id)) { div.style.backgroundColor = "#fff5de"; } } catch(err) { } try{ if (div = document.getElementById("hotel_"+hotel_id+"_number")) { div.style.backgroundImage = "url(http://www.matchhotels.com/moplugin/images/icons/map_hotel_selected_smal.gif)"; } } catch(err) { } try{ if (markers[hotel_id]) { markers[hotel_id].setImage("http://www.matchhotels.com/moplugin/images/icons/map_hotel_selected_smal.gif"); } } catch(err) { } } function hotel_set_not_selected_icon(hotel_id) { try{ if (div = document.getElementById("hotel_"+hotel_id)) { div.style.backgroundColor = ""; } } catch(err) { } try{ if (div = document.getElementById("hotel_details_"+hotel_id)) { div.style.backgroundColor = ""; } } catch(err) { } try{ if (div = document.getElementById("hotel_"+hotel_id+"_number")) { div.style.backgroundImage = "url(http://www.matchhotels.com/moplugin/images/icons/map_hotel_not_selected_smal.gif)"; } } catch(err) { } try{ if (markers[hotel_id]) { markers[hotel_id].setImage("http://www.matchhotels.com/moplugin/images/icons/map_hotel_not_selected_smal.gif"); } } catch(err) { } }