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] = "

"+PropertyList['office_name'][1]+"

"+PropertyList['full_address'][1]+"

No property can be shown on the map because property addresses are hidden.

"; propCoor = australiaCoor; geocoder.geocode( { 'address': PropertyList['full_address'][1]}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { propCoor = results[0].geometry.location; marker = new google.maps.Marker({ icon: marker_icon, shadow: marker_shadow, position: propCoor, map: map }); infowindow.setContent(message[i]); infowindow.setSize(infowindow_size); infowindow.open(map, marker); bounds.extend(marker.position); map.fitBounds(bounds); } }); } else { bookmark = (typeof(PropertyList['pj_listings']) != 'undefined')?'':''; message[i] = '

'+PropertyList['address'][i]+', '+PropertyList['suburb'][i]+'

'+PropertyList['price'][i]+'

'+PropertyList['bbc'][i]+'

'; propCoor = new google.maps.LatLng(PropertyList['lt_lat'][i],PropertyList['lt_log'][i]); marker = new google.maps.Marker({ icon: marker_icon, shadow: marker_shadow, position: propCoor, map: map }); if(typeof(PropertyList['sale_type']) != 'undefined' && PropertyList['sale_type'][i] == 'rent') { marker.setIcon(marker_icon_ex); } bounds.extend(marker.position); map.fitBounds(bounds); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(message[i]); infowindow.setSize(infowindow_size); infowindow.open(map, marker); } })(marker, i)); } } } } function officeMapView(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(); geocoder = new google.maps.Geocoder(); for (var i in PropertyList['office_address']) { propCoor = null; message[i] = '

'+PropertyList['office_name'][i]+'

'+PropertyList['office_address'][i]+'

'; propCoor = new google.maps.LatLng(PropertyList['ofc_lat'][i],PropertyList['ofc_log'][i]); marker = new google.maps.Marker({ icon: marker_icon, shadow: marker_shadow, position: propCoor, map: map }); bounds.extend(marker.position); map.fitBounds(bounds); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(message[i]); infowindow.setSize(infowindow_size); infowindow.open(map, marker); } })(marker, i)); } } function codeCoord(canvas, PropLatlng, PropAddress) { var contentString = '

'+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); } }); }