在传单中禁用 Geosearch esri 控件
Disable Geosearch esri controls in leaflet
可以在第一次地理编码搜索后禁用 leaflet 中的 Geosearch esri 控件吗?当我 运行 chrome 控制台和我 select 搜索地理编码图标时,这是代码:<input class="geocoder-control-input leaflet-bar">
,我尝试使用 $('.geocoder-control-input leaflet-bar').attr('disabled', true);
禁用但不起作用。
提前致谢。
您代码中的某处(您未共享)正在初始化控件并将其添加到地图中。像这样:
var geosearch = L.esri.Geocoding.geosearch(...).addTo(map);
或者像这样:
var geosearch = L.esri.Geocoding.geosearch(...);
map.addControl(geosearch);
如果您永远不需要控件,您可以删除这些行。如果您希望以后能够添加它,您可以删除 .addTo(map)
或 map.addControl(geosearch)
部分。添加后,您可以使用 L.Map
的 removeControl
方法将其删除 简而言之,它的工作原理如下:
var geosearch = L.esri.Geocoding.geosearch(...);
// Add control to the map
map.addControl(geosearch);
// Remove control from the map
map.removeControl(geosearch);
参考文献:
可以在第一次地理编码搜索后禁用 leaflet 中的 Geosearch esri 控件吗?当我 运行 chrome 控制台和我 select 搜索地理编码图标时,这是代码:<input class="geocoder-control-input leaflet-bar">
,我尝试使用 $('.geocoder-control-input leaflet-bar').attr('disabled', true);
禁用但不起作用。
提前致谢。
您代码中的某处(您未共享)正在初始化控件并将其添加到地图中。像这样:
var geosearch = L.esri.Geocoding.geosearch(...).addTo(map);
或者像这样:
var geosearch = L.esri.Geocoding.geosearch(...);
map.addControl(geosearch);
如果您永远不需要控件,您可以删除这些行。如果您希望以后能够添加它,您可以删除 .addTo(map)
或 map.addControl(geosearch)
部分。添加后,您可以使用 L.Map
的 removeControl
方法将其删除 简而言之,它的工作原理如下:
var geosearch = L.esri.Geocoding.geosearch(...);
// Add control to the map
map.addControl(geosearch);
// Remove control from the map
map.removeControl(geosearch);
参考文献: