Skip to content

Instantly share code, notes, and snippets.

@propertyhive
Last active June 15, 2016 14:23
Show Gist options
  • Save propertyhive/e437dd2465430c7cfce014f610f2f2bc to your computer and use it in GitHub Desktop.
Save propertyhive/e437dd2465430c7cfce014f610f2f2bc to your computer and use it in GitHub Desktop.
Display map on Property Hive full details page
<div id="map_canvas" style="height:300px"></div>
<script src="http://maps.google.com/maps/api/js"></script>
<script>
var map; // Global declaration of the map
function initialize_map() {
var myLatlng = new google.maps.LatLng(<?php echo $property->latitude; ?>, <?php echo $property->longitude; ?>);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var myLatlng = new google.maps.LatLng(<?php echo $property->latitude; ?>, <?php echo $property->longitude; ?>);
var markerOptions = {
map: map,
position: myLatlng
};
marker = createMarker(markerOptions);
}
function createMarker(markerOptions) {
var marker = new google.maps.Marker(markerOptions);
return marker;
}
google.maps.event.addDomListener(window, "load", initialize_map);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment