Hello Admin,
In one of my clonable templates I have a div that shows a google map at the admin area like this:
. I want to feed the script that renders the map with the coordinates from the current cloned page. I am attempting to get the field that with
I also tried
In one of my clonable templates I have a div that shows a google map at the admin area like this:
- Code: Select all
<cms:template title='Things to see and do' clonable='1' paginate='1' dynamic_folders='1' order="1">
<cms:editable name='lat' label='Latitude' type='text' order='28' />
<cms:editable name='lng' label='Longitude' type='text' order='29' />
<cms:editable name='gmap' type='message' order='30'>
<div id="mapid" style="width:100%;height:400px;" class="shadow"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=API-KEY&libraries=geometry&libraries=places"></script>
<script>
function initialize() {
var input = document.getElementById('f_location');
var options = {
componentRestrictions: {
country: "gh"
}
};
var autocomplete = new google.maps.places.Autocomplete(input, options);
var map = new google.maps.Map(document.getElementById('mapid'), {
center: {
lat: <cms:show lat />,
lng: <cms:show lng />
}, // Accra, Ghana
zoom: 12
});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
var place = autocomplete.getPlace();
if (!place.geometry) {
console.log("Returned place contains no geometry");
return;
}
if (place.geometry.viewport) {
map.fitBounds(place.geometry.viewport);
} else {
map.setCenter(place.geometry.location);
map.setZoom(17);
}
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
// Update hidden input fields with latitude and longitude
document.getElementById('f_lat').value = place.geometry.location.lat();
document.getElementById('f_lng').value = place.geometry.location.lng();
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</cms:editable>
</cms:template>
. I want to feed the script that renders the map with the coordinates from the current cloned page. I am attempting to get the field that with
- Code: Select all
<cms:show lat />
I also tried
- Code: Select all
<cms:get_field 'lat' page="<cms:show k_page_name />" />