/**
 * JavaScript for map display on property pages.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS\module\property
 * @copyright Copyright (c) 2016 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

$fl(document).ready(function() {

	function setupMap(latitude, longitude) {
		// create a JSON object with the values to mark the position
		var _position = { lat: latitude, lng: longitude};

		// add our default mapOptions
		var mapOptions = {
			zoom: 16, // zoom level of the map
			center: _position // position to center
		}

		// load a map within the "map" div and display
		var map = new google.maps.Map(document.getElementById('propertyMap'), mapOptions);

		var panorama = new google.maps.StreetViewPanorama(
			document.getElementById('properyStreetView'), {
				position: _position,
				pov: {
					heading: 0,
					pitch: 10
				}
			});
		map.setStreetView(panorama);

		var marker = new google.maps.Marker({
			position: mapOptions.center,
			map: map
		});
	}

	setupMap(parseFloat($fl('#propertyLat').val()), parseFloat($fl('#propertyLng').val()));
});
