-1

A part of my html code

var marker;

function initMap() {

    map = new google.maps.Map(document.getElementById("mymap"), myOptions);
    getMapMetadata([]);

    // setInterval(function(){ getMapMetadata([]); }, 3000);
}


function createMarker(latlng, label, html) {

    // alert("createMarker("+latlng+","+label+","+html+","+color+")");
    var contentString = '<b>' + label + '</b><br>' + html;
    var image;
    image = 'static/img/30.png';
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon: image,
        title: label,
        zIndex: Math.round(latlng.lat() * -100000) << 5
    });
    marker.myname = label;
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent(contentString);
        infowindow.open(map, marker);
    });
    return marker;
}

function getMapMetadata(ids) {

    $.get("{% url 'app01:cate' %}", { ids: [] }, function(data, status) {
                console.log("Data: " + JSON.stringify(data) + "\nStatus: " + status);
                var metadata;
                var i;
                //for(var i=0;  i<data.length; i++)
                metadata = JSON.parse(JSON.stringify(data));
                for (i = 0; i < metadata.length; i++) {
                    console.log("item: " + metadata[i].x);
                    marker = createMarker(new google.maps.LatL ng(metadata[i].x, metadata[i].y), metadata[i].id + "", JSON.stringify(metadata[i]));

A part of views

uavs = [Map.objects.get(pk=str(i)) for i in range(1, NUAVs+1)]

I want to add this variable which contains the variation of value of 2 points, to the marker in my template

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159

1 Answers1

0

What does the rest of your views look like?

Read the docs on making views, here and some examples

You would pass the uavs variable from the view to the template, and access it using "{{uavs}}"

NS0
  • 6,016
  • 1
  • 15
  • 14
  • {% for u in uavs %} x={{u.x}} y={{u.y}} marker=createMarker(new google.maps.LatLng(metadata[i].x,metadata[i].y),metadata[i].id+"",JSON.stringify(metadata[i])); {% endfor%} but it does not work – selma moula Mar 15 '17 at 18:38