0

我是 Angular 的新手,所以我需要一些帮助来了解如何在markers.venues.

我的代码是:

var app = angular.module("basicMapApp", ["leaflet-directive"]);
app.controller("CenterController",
    [ '$scope', function($scope) {
        angular.extend($scope, {
            defaults: {
                tileLayer: "https://dnv9my2eseobd.cloudfront.net/v3/foursquare.map-ikj05elx/{z}/{x}/{y}.png",
                maxZoom: 14,
                minZoom: 3,
            },
             center: {
                lat: 52.38,
                lng: 4.8777,
                zoom: 6
            },
             markers: {
                venues: {
                    Madrid: {
                        lat: 52.38,
                        lng: 4.8777,
                        message: "This is Madrid. But you can drag me to another position",
                        focus: false,
                        draggable: true
                    },
                    Barcelona: {
                        lat: 52.38,
                        lng: 5.8777,
                        message: "This is Barcelona. You can't drag me",
                        focus: false,
                        draggable: false
                    }
                }
            }
        });

    }]
);

如何markers.venues在 javascript 中添加新项目?

例如我试过但没有用:

 $scope.markers.venues.push({
    Amsterdam: {
                 lat: 52.38,
                 lng: 5.9777,
                 message: "This is Amsterdam. You can't drag me",
                 focus: false,
                 draggable: false
              }
     });

角传单记录在这里

4

1 回答 1

0

尝试这个

   $scope..markers.venues['Amsterdam']={
             lat: 52.38,
             lng: 5.9777,
             message: "This is Amsterdam. You can't drag me",
             focus: false,
             draggable: false
          }
于 2013-10-15T11:59:51.807 回答