仿链家地图找房_【前端-自如/链家/安居客-地图找房】地图api如何获取浏览器视野范围内的经纬度区间?...
在群里請教了大能,解決啦~用map.getBounds()即可!下面是代碼~
const map = new AMap.Map('mapContainer', {
resizeEnable: true,
center: [init_longitude, init_latitude],
zoom: 10
});
/* 大家console下面的getBounds,會有驚喜~
** 我這里是用的高德,百度也有getBounds!
** */
console.log(map.getBounds(), '=====')
/* 敲一下下面的代碼就明白了~
** 點標記:中心點-天安門 */
const marker = new AMap.Marker({
position: ['116.397428','39.90923'],
title: '中心點-天安門',
animation: 'AMAP_ANIMATION_DROP'
});
marker.setMap(map);
const bounds = map.getBounds()
/* 點標記:瀏覽器的東北角 */
const marker2 = new AMap.Marker({
position: [bounds.northeast.N,bounds.northeast.Q],
title: '瀏覽器的東北角',
animation: 'AMAP_ANIMATION_BOUNCE'
});
/* 點標記:瀏覽器的西南角 */
marker2.setMap(map);
const marker3 = new AMap.Marker({
position: [bounds.southwest.N,bounds.southwest.Q],
title: '瀏覽器的西南角',
animation: 'AMAP_ANIMATION_BOUNCE'
});
marker3.setMap(map);
總結
以上是生活随笔為你收集整理的仿链家地图找房_【前端-自如/链家/安居客-地图找房】地图api如何获取浏览器视野范围内的经纬度区间?...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: K均值与DBSCAN聚类效果
- 下一篇: [AngularJS] 插件ui-gri