[英]Mapbox Display Lat and Lng and Zoom then putting them inside a textbox
enter image description here在此处输入图片说明
I was wondering how to actually get the lat and lng and zoom values like in the picture example on mapbox style builder not with a mouse click or with a mouse move, just the entire map inside a div.我想知道如何像在地图框样式构建器上的图片示例中那样实际获取 lat 和 lng 以及缩放值,而不是通过鼠标单击或鼠标移动,而只是在 div 中获取整个地图。
So explaining in detail, I was wondering if there was a way to grab the maps coordinates and display them based off of what mapbox does in there studio editor.所以详细解释一下,我想知道是否有办法获取地图坐标并根据 mapbox 在工作室编辑器中的作用来显示它们。 They calculate the lat and lng and zoom level of their whole map and when a user scrolls around the map the lat and lng changes and it displays the new coordinates with the zoom level.他们计算整个地图的 lat 和 lng 以及缩放级别,当用户在地图上滚动时,lat 和 lng 会发生变化,并显示具有缩放级别的新坐标。 I need to take those values and place them inside a textbox.我需要获取这些值并将它们放在文本框中。
You have several samples on this.你有这方面的几个样本。
how to get the coords of a point 如何获得一个点的坐标
how to create a draggable marker 如何创建可拖动标记
how to get the coords of cursor如何获取光标的坐标
If you need the zoom too, you only need to addmap.getZoom()
to he methods that are painting the lngLat.lng
and lngLat.lat
如果您也需要缩放,则只需将map.getZoom()
添加到绘制lngLat.lng
和lngLat.lat
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.