Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Leaflet 重用传单指令的现有地图实例_Leaflet_Angular Leaflet Directive - Fatal编程技术网

Leaflet 重用传单指令的现有地图实例

Leaflet 重用传单指令的现有地图实例,leaflet,angular-leaflet-directive,Leaflet,Angular Leaflet Directive,我正在尝试向当前地图添加由传单指令创建的地图。我使用以下命令获取L.map实例: leafletData.getMap().then(function(map) { // where map is the Leaflet map instance } 但是,创建地图时,传单可编辑需要设置可编辑:true 那么,有没有办法创建一个L.map实例 var map = L.map('map', {editable: true}); 然后把它贴在传单上 更新: 我试图在传单上加一个钩子 L.Ma

我正在尝试向当前地图添加由传单指令创建的地图。我使用以下命令获取L.map实例:

leafletData.getMap().then(function(map) {
  // where map is the Leaflet map instance
}
但是,创建地图时,传单可编辑需要设置
可编辑:true

那么,有没有办法创建一个L.map实例

var map = L.map('map', {editable: true});
然后把它贴在传单上

更新:

我试图在传单上加一个钩子

L.Map.addInitHook(function () {
  this.whenReady(function () {
    this.editTools = new L.Editable(this, this.options.editOptions);
    console.log('L.map', this);
  });
}
它成功地创建了editTools,但是

map.editTools.startPolyline(); 

仍不工作

是否尝试将
可编辑:true
添加到默认值

angular.extend($scope, {
    defaults: {
        editable: true
    },
    center: {
        lat: 51.505,
        lng: -0.09,
        zoom: 8
    }
});

<leaflet defaults="defaults" lf-center="center" height="480px" width="640px"></leaflet>
angular.extend($scope{
默认值:{
可编辑:真
},
中心:{
拉脱维亚:51.505,
液化天然气:-0.09,
缩放:8
}
});

对于任何像我这样的人,都可以使现有地图可编辑

var map = L.map('map', {editable: true});

var map = L.map('map');
map.editTools = new L.Editable(map);

您可以通过检查map实例的options对象来验证它是否真的设置了:
console.log(map.options.editable)将可编辑属性添加到默认值根本不起作用。我已经用最后一次尝试更新了这个问题