将Leaflet添加到我的AngularJS应用程序后:
<leaflet id="map" defaults="defaults" center="center" bounds="bounds" controls="controls" event-broadcast="events"></leaflet>
并设置:
// Initialise the feature group to store editable layers var drawnItems = new L.FeatureGroup(); // Initialise the draw control var drawControl = new L.Control.Draw({ position: 'topright',edit: { featureGroup: drawnItems } }); // Configure Leaflet angular.extend($scope,{ defaults: { zoomControlPosition: 'topright',minZoom: 3,tileLayerOptions: { detectRetina: true,reuseTiles: true,attribution: '<a href="http://osm.org">OpenStreetMaps</a>' } },center: {},controls: { custom: [drawControl] },events: { map: { enable: ['click'] } } });
leafletData.getMap().then( function (map) { alert('I have accessed the map.'); } );
尽管没有任何反应,这应该会立即向我显示警报.
如果我延迟这个以前的代码,例如,在单击按钮的函数中运行它,它就可以了!
有谁知道什么可能是一个问题?
部分解决
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。