How to make a $ scope of location with geodjango, django and angularjs

0

How to make a $ scope.cities because I do not get it in PHPStorm I get an error of "Expression statement is not assignment or call" and I do not know what the error is

/**
 * Created by gamba on 20/10/2016.
 */
var app = angular.module("mapas",[]);

app.controller("myctrl",function ($scope,$http) {
    //CONEXION
    $scope.coordenadas=[];
    $scope.cities=[];
    var url = "http://192.168.137.11:8000/conductores/";
    $http({
        method: 'GET',
        url: url
    }).then (function successCallback(data) {
        $scope.coordenadas=data;
        $scope.cities = [
            {'Bus 1',$scope.coordenadas[1].ubicacion.geometry.x,$scope.coordenadas[1].ubicacion.geometry.y},
            {'Bus 2',$scope.coordenadas[2].ubicacion.geometry.x,$scope.coordenadas[2].ubicacion.geometry.y},
            {'Bus 3',$scope.coordenadas[3].ubicacion.geometry.x,$scope.coordenadas[3].ubicacion.geometry.y}
        ];
    },function errorCallback(err) {
        console.log("No funciona la conexion");
    });
    //GOOGLE MAPS API CODE
    var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(40.0000, -98.0000),
        mapTypeId: google.maps.MapTypeId.TERRAIN
    };

    $scope.map = new google.maps.Map(document.getElementById('map'), mapOptions);

    $scope.markers = [];

    var infoWindow = new google.maps.InfoWindow();

    var createMarker = function (info){

        var marker = new google.maps.Marker({
            map: $scope.map,
            position: new google.maps.LatLng(info.lat, info.long),
            title: info.city
        });
        marker.content = '<div class="infoWindowContent">' + info.desc + '</div>';

        google.maps.event.addListener(marker, 'click', function(){
            infoWindow.setContent('<h2>' + marker.title + '</h2>' + marker.content);
            infoWindow.open($scope.map, marker);
        });

        $scope.markers.push(marker);

    };

    for (i = 0; i < $scope.cities.length; i++){
        createMarker($scope.cities[i]);
    }

    $scope.openInfoWindow = function(e, selectedMarker) {
        e.preventDefault();
        google.maps.event.trigger(selectedMarker, 'click');
    }
});
    
asked by Anthony Rosas 07.12.2016 в 22:48
source

1 answer

1

You have an error in the way you are writing the arrangement on line 16 you have:

$scope.cities = [
        {'Bus 1',$scope.coordenadas[1].ubicacion.geometry.x,$scope.coordenadas[1].ubicacion.geometry.y},
        {'Bus 2',$scope.coordenadas[2].ubicacion.geometry.x,$scope.coordenadas[2].ubicacion.geometry.y},
        {'Bus 3',$scope.coordenadas[3].ubicacion.geometry.x,$scope.coordenadas[3].ubicacion.geometry.y}
    ];

when it should be:

$scope.cities = [
    ['Bus1',$scope.coordenadas[1].ubicacion.geometry.x,$scope.coordenadas[1 ].ubicacion.geometry.y],
    ['Bus2',$scope.coordenadas[2].ubicacion.geometry.x,$scope.coordenadas[2].ubicacion.geometry.y], 
    ['Bus3',scope.coordenadas[3].ubicacion.geometry.x,$scope.coordenadas[3].ubicacion.geometry.y]
];

In other words, you confused "{" with "]".

    
answered by 11.12.2016 в 04:24