仿链家地图找房-尊龙游戏旗舰厅官网
在群里请教了大能,解决啦~用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如何获取浏览器视野范围内的经纬度区间?...的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇:
- 下一篇: