简体   繁体   English

Mapzen搜索-缩放到搜索图钉

[英]Mapzen Search - Zoom to Search Pin

I am developing a Leaflet map that includes a MapZen address search. 我正在开发一个包含MapZen地址搜索的Leaflet地图。 I cant find any information on how to zoom in on the search pin after an address is selected and the map pans to the pin. 选择地址并映射到该图钉后,我找不到有关如何放大搜索图钉的任何信息。 Does anyone know how to do this? 有谁知道如何做到这一点?

Thank you, 谢谢,

Nick 缺口

Have you taken a look at mapzen.js? 您看过mapzen.js吗? It's a Leaflet extension that provides a search box that autozooms to the selected result. 这是一个Leaflet扩展,它提供一个搜索框,可自动缩放到所选结果。

https://mapzen.com/documentation/mapzen-js/ https://mapzen.com/documentation/mapzen-js/

https://mapzen.com/documentation/mapzen-js/search/ https://mapzen.com/documentation/mapzen-js/search/

Mapzen Leaflet Geocoder (which is part of mapzen.js) doesn't offer zoom level change by default when the result's geometry type is point. 当结果的几何类型为点时,默认情况下,Mapzen Leaflet Geocoder(属于mapzen.js的一部分)不提供缩放级别更改。 However, you can listen to the events that Geocoder element fires, execute setZoom . 不过,您可以侦听Geocoder元素触发的事件,执行setZoom You can check all the events that Mapzen Leaflet Geocoder fires here: https://github.com/mapzen/leaflet-geocoder#events 您可以在此处检查Mapzen Leaflet Geocoder触发的所有事件: https : //github.com/mapzen/leaflet-geocoder#events

This is the example snippet listening to select event, change the zoom level of the map. 这是侦听select事件,更改地图缩放级别的示例片段。

var map = L.Mapzen.map('map');
map.setView([0,0], 13);

var geocoder = L.Mapzen.geocoder();
geocoder.addTo(map);

var desiredZoomLevel = 17;

wgeocoder.on('select', function (e) {
map.setZoom(desiredZoomLevel);
});

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

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