2👍
✅
Use the {{ variable }}
syntax.
function displayRoads(map) {
{% for create_lat_lng in get_lat_lng %}
{% for lat_lng in create_lat_lng %}
var points = new google.maps.MVCArray();
points.push(new google.maps.LatLng({{ lat_lng.0.lat }}, {{ lat_lng.0.lng }}));
points.push(new google.maps.LatLng({{ lat_lng.1.lat }}, {{ lat_lng.1.lng }}));
createPolyline(map, points);
{% endfor %}
{% endfor %}
}
Just to clarify, {{ lat_lng.0.lat }}
means access index zero on the lat_lng
variable, and then get the value of the dictionary key lat
. So the code above assumes lat_lng
is a array/tuple containing dictionaries.
Source:stackexchange.com