繁体   English   中英

将项目推入数组//角形小叶

[英]Push item in array // Angular leaflet

我是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
                    }
                }
            }
        });

    }]
);

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

例如,我尝试了但没有成功:

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

此处有角传单

尝试这个

   $scope..markers.venues['Amsterdam']={
             lat: 52.38,
             lng: 5.9777,
             message: "This is Amsterdam. You can't drag me",
             focus: false,
             draggable: false
          }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM