Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JonasEriksson/222b1528b4ff96217c0b9d36b255f18c to your computer and use it in GitHub Desktop.
Save JonasEriksson/222b1528b4ff96217c0b9d36b255f18c to your computer and use it in GitHub Desktop.
Script for Google Map coordinates based on Mura CMS Extended Data for Site Settings.
<!--- Requires three Extended Attributes on Site/Default: GoogleMapsZoomFactor,GPSPositionLongitude,GPSPositionLatitude. --->
<!--- To get the coordinates, simply select a point on Google Maps and right-click "What's here" to get the Coordinates --->
<!--- for a place. Then chose the Zoom Factor that suits the map. Enter those values in Edit Site -> Extended Attributes --->
<!--- place this in a column in the contact form or whereever the map should be shown --->
<!-- Map container -->
<div id="map-container" class="z-depth-1 wow fadeInUp" style="height: 300px"></div>
<!-- /.Map-container -->
<!--- place code below in the footer just above the body end tag --->
<!-- Google Maps Script -->
<script src="http://maps.google.com/maps/api/js"></script>
<cfoutput>
<script>
function init_map() {
var var_location = new google.maps.LatLng(#$.siteConfig('GPSPositionLongitude')#, #$.siteConfig('GPSPositionLatitude')#);
var var_mapoptions = {
center: var_location,
zoom: #$.siteConfig('GoogleMapsZoomFactor')#
};
var var_marker = new google.maps.Marker({
position: var_location,
map: var_map,
title: "New York"
});
var var_map = new google.maps.Map(document.getElementById("map-container"),
var_mapoptions);
var_marker.setMap(var_map);
}
google.maps.event.addDomListener(window, 'load', init_map);
</script>
</cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment