角传单搜索控制事件 [英] Angular Leaflet Search control event
本文介绍了角传单搜索控制事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个AngularJS应用程序,当前正在尝试访问传单搜索控件,但是没有运气.
I have an AngularJS application and I'm currently trying to access the "search_expanded" event of Leaflet Search control but having no luck.
这是我的代码:
angular.module('myApp', [ 'leaflet-directive' ])
.controller('ShowMapCtrl', ["$scope", "leafletData", function ($scope, leafletData) {
// some code
leafletData.getMap().then(function(map) {
map.on('search_expanded', function(e){
alert("search control expannded");
});
});
推荐答案
search_expanded
事件以及L.Control.Search
支持的所有其他事件都在实际的控件实例上触发,而不是在地图实例上触发,如您所见.以下示例:
The search_expanded
event, and all the other events supported by L.Control.Search
are fired on the actual control instance not on the map instance as you can see in the following example:
var controlSearch = new L.Control.Search({
layer: new L.LayerGroup()
}).on('search_expanded', function () {
console.log('search_expanded!')
}).addTo(map);
http://plnkr.co/edit/njeXYb4PfbaG3hppcgmO?p=preview
这篇关于角传单搜索控制事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文