I am using Google map api and i am trying to pass the data (longitude and latitude) to the template then use the data in the javascript to show a specific location.
location.html
{% for venue in property_listing %}
{{ venue.address }}</br>
<div id="long">{{ venue.longitude }}</br>
<div id="lat">{{ venue.latitude }}</br>
{% endfor %}
javascript of the same page
<script>
var latitude = REPLACE HERE;
var longitude = REPLACE HERE;
// Initialize and add the map
function initMap() {
// The location of Uluru
var uluru = {lat: latitude, lng: longitude};
// The map, centered at Uluru
var map = new google.maps.Map(
document.getElementById('map'), {zoom: 15, center: uluru});
// The marker, positioned at Uluru
var marker = new google.maps.Marker({position: uluru, map: map});
}
</script>
I am tried to replace the value literally but it wont work. What is the best way to solve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…