First of all, I am a newbie at programming. I am trying to make a web page where you have a Google Map embedded, and in this Map you can see a colored line that sets a path. For this, I am using Django. In my views.py I have a variable called points, where I have some coordinates written in a list, as a string. For example,
points = ('-15.4566620,28.07163320','15.7566620,29.07163320',....)
Then, in the google maps script, I have:
var flightPlanCoordinates = [
new google.maps.LatLng(-15.4566620,28.07163320),
new google.maps.LatLng(-15.7566620,29.07163320),
];
So when I display my page, I see a line between those points.
I would like to have, instead of that, something like:
var flightPlanCoordinates = [
{% for point in points %}
new google.maps.LatLng({{point}}),
{% endfor %}
];
But this doesn't work.
What am I doing wrong, and how should it be?
Thank you very much.
mydictvariable to the template the same way, inside render_to_response{ 'points': points, 'mydict': mydict }, and to access the value in the template, use dot notation{{ mydict.mykey }}. See this page for iterating the dictionary, the key-value part: docs.djangoproject.com/en/dev/ref/templates/builtins/#for