Hi,
I have the map working on the backend which is great but how do I pull it through to a page on the frontend?
I tried to follow the instructions in another thread but, I could be wrong, but it seemed to be for Umbraco 6?
@{
var lat = CurrentPage.location.Latitude;
var lng = CurrentPage.location.Longitude;
var zoom = CurrentPage.location.Zoom;
var latlng = lat+","+lng;
}
<!-- GOOGLE MAPS -->
<style type="text/css">
html, body, #map-canvas { height: 200px; margin: 0; padding: 0;}
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=[YOUR-API-KEY]">
</script>
<script type="text/javascript">
function initialize() {
var myLatlng = new google.maps.LatLng(@latlng);
var mapOptions = {
center: { lat: @lat, lng: @lng},
zoom: 11
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Hello World!',
animation: google.maps.Animation.DROP
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
The section above the GOOGLE MAP comment is populated from this project, so if you call your map property myMap within the datatype, you need to change location to myMap.
How to make this work in Umbraco 7?
Hi, I have the map working on the backend which is great but how do I pull it through to a page on the frontend? I tried to follow the instructions in another thread but, I could be wrong, but it seemed to be for Umbraco 6?
Any instructions would be great. Thanks.
To help others, I have now got this to work.
On my page template I have -
The section above the GOOGLE MAP comment is populated from this project, so if you call your map property myMap within the datatype, you need to change location to myMap.
e.g.
becomes
You will need to get your own API Key. I just followed the instructions on here: https://developers.google.com/maps/documentation/javascript/tutorial to get mine and then just replace the [YOUR-API-KEY] with your API in the code.
You then place a Div where you want the map to display :
Simple!
is working on a reply...