var australiaCoor = new google.maps.LatLng(-29.509726, 135.625); var geocoder; var map; var directionDisplay; var directionsService; var marker_icon = new google.maps.MarkerImage(SITE_PATH+'img/google_pin.png', new google.maps.Size(23, 30), new google.maps.Point(0,0), new google.maps.Point(12, 30)); var marker_shadow = new google.maps.MarkerImage(SITE_PATH+'img/icon_shadow.png', new google.maps.Size(39, 30), new google.maps.Point(0,0), new google.maps.Point(12, 30)); var marker_icon_ex = new google.maps.MarkerImage(SITE_PATH+'img/google_pin_ex.png', new google.maps.Size(23, 30), new google.maps.Point(0,0), new google.maps.Point(12, 30)); var marker_shadow_ex = new google.maps.MarkerImage(SITE_PATH+'img/icon_shadow_ex.png', new google.maps.Size(39, 30), new google.maps.Point(0,0), new google.maps.Point(12, 30)); function showMap(canvas) { if(typeof(PropLatlng) != "undefined" && (PropLatlng.lat() != 0 && PropLatlng.lng() != 0)) { if(parseInt(PropLatlng.lat()) == 0 || parseInt(PropLatlng.lng()) == 0 || parseInt(PropLatlng.lat()) == 1 || parseInt(PropLatlng.lng()) == 1) { codeAddress("google-canvas", PropAddress); }else { codeCoord(canvas, PropLatlng, PropAddress); } }else { codeAddress("google-canvas", PropAddress); } } function mapView(canvas, PropertyList) { markers = []; var bounds = new google.maps.LatLngBounds(); var myOptions = { streetViewControl: true, scrollwheel: false, zoom: 5, maxZoom:20, center: australiaCoor, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById(canvas), myOptions); var infowindow = new google.maps.InfoWindow(); var infowindow_size = new google.maps.Size(320,120); var marker, i; var message = new Array(); for (var i in PropertyList['full_address']) { propCoor = null; if(parseFloat(PropertyList['lt_lat'][i]) === 0 || parseFloat(PropertyList['lt_log'][i]) === 0 || parseFloat(PropertyList['lt_lat'][i]) === 1 || parseFloat(PropertyList['lt_log'][i]) === 1) { continue; }else { if(PropertyList['no_record'][1]) { geocoder = new google.maps.Geocoder(); message[i] = "
No property can be shown on the map because property addresses are hidden.
'+PropertyList['bbc'][i]+'
'+PropertyList['office_name'][i]+'
'+PropertyList['office_address'][i]+'
'+PropAddress+'
' var marker = displayPin(canvas, PropLatlng); bindInfo(marker, map, contentString, ''); } function codeAddress(canvas, PropAddress) { geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': PropAddress}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { if(typeof(hideAddress) == 'undefined' || !hideAddress) { var contentString = ''+PropAddress+'
'; var marker = displayPin(canvas, results[0].geometry.location, map); bindInfo(marker, map, contentString, ''); }else { if(hideAddress) { displayPin(canvas, results[0].geometry.location, map, true); } } } else { alert("Property map can not be retrieved by the following reason: " + status); } }); } function displayPin(canvas, coord, target_map, map_only) { if(typeof(map) == 'undefined') { var myOptions = { streetViewControl: true, scrollwheel: false, zoom: 15, center: coord, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById(canvas), myOptions); }else { map = target_map; } if(typeof(map_only) == 'undefined' || !map_only) { var marker = new google.maps.Marker({ icon: marker_icon, shadow: marker_shadow, position:coord, map: map }); } return marker; } function bindInfo(marker, map, content, size, target_iw) { if(typeof(infoWindow) == 'undefined') { var infowindow = new google.maps.InfoWindow({ content: content }); }else { var infowindow = target_iw; } if(size != '') {infowindow.setSize(size);} google.maps.event.addListener(marker, 'click', function() { infowindow.open(map,marker); }); } function streetView(canvas, PropAddress) { if(typeof(PropLatlng) != "undefined" && (PropLatlng.lat() != 0 && PropLatlng.lng() != 0)) { if(parseInt(PropLatlng.lat()) == 0 || parseInt(PropLatlng.lng()) == 0 || parseInt(PropLatlng.lat()) == 1 || parseInt(PropLatlng.lng()) == 1) { streetAddress(canvas, PropAddress); }else { streetCoord(canvas, PropLatlng, PropAddress); } }else { streetAddress(canvas, PropAddress); } } function streetAddress(canvas, PropAddress) { geocoder = new google.maps.Geocoder(); geocoder.geocode( { 'address': PropAddress}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { var streetViewPosition = results[0].geometry.location; loadStreetView(canvas, streetViewPosition); }else { //unfinished business panoramaOptions = { }; } }); } function streetCoord(canvas, PropLatlng, PropAddress) { loadStreetView(canvas, PropLatlng); } function loadStreetView(canvas, PropLatlng) { var panoramaOptions = { addressControl: true, addressControlOptions: { style: { backgroundColor: 'lightgrey', color: 'black' } }, position:PropLatlng, pov: { heading: 165, pitch:0 }, zoom:0 }; var myPano = new google.maps.StreetViewPanorama(document.getElementById(canvas), panoramaOptions); } function showDirections(canvas, panel, ToAddress) { directionsService = new google.maps.DirectionsService(); directionsDisplay = new google.maps.DirectionsRenderer(); geocoder = new google.maps.Geocoder(); var default_coor; geocoder.geocode({'address': ToAddress}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { default_coor = results[0].geometry.location; var myOptions = { zoom: 15, center: default_coor, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById(canvas), myOptions); directionsDisplay.setMap(map); directionsDisplay.setPanel(document.getElementById(panel)); if(!getDirection) { var marker = new google.maps.Marker({ position:results[0].geometry.location, map: map }); } } }); } function calcRoute(start, end) { var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); }