百度地图 polygon点击事件_获取百度地图区域边界位置信息 - 县区以下边界的获取...

一:获取百度地图区域边界

e03faa4db91ef4b01fe1cecaabed461a.png

二:实现方式

1)获取区域的uid

百度地图获取uid链接:

http://map.baidu.com/su?wd=宁围&cid=179&type=0&pc_ver=2

结果值:

14486f9c21b3b2e55f2ba12e76f02da7.png

2)根据uid获取区域的geo信息

根据第一步获取的uid获取区域geo信息,获取链接:

http://map.baidu.com/?pcevaname=pc4.1&qt=ext&ext_ver=new&l=12&uid=e99f8233af8311bfeb12e4ff

结果值:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于获取百度地图可视范围内的坐标,可以通过以下步骤实现: 1. 获取百度地图的可视区域: ``` BaiduMap baiduMap = mMapView.getMap(); MapStatus mapStatus = baiduMap.getMapStatus(); LatLngBounds latLngBounds = mapStatus.bound; ``` 2. 获取可视区域的四个顶点坐标: ``` LatLng northeast = latLngBounds.northeast; // 东北角坐标 LatLng southwest = latLngBounds.southwest; // 西南角坐标 LatLng northwest = new LatLng(northeast.latitude, southwest.longitude); // 西北角坐标 LatLng southeast = new LatLng(southwest.latitude, northeast.longitude); // 东南角坐标 ``` 这样就能够获取到百度地图可视范围内的四个顶点坐标了。 至于自定义划分区域获取区域内的坐标点,可以通过以下步骤实现: 1. 自定义一个多边形区域: ``` List<LatLng> points = new ArrayList<>(); points.add(new LatLng(39.961316, 116.465088)); points.add(new LatLng(39.936529, 116.465088)); points.add(new LatLng(39.936529, 116.491394)); points.add(new LatLng(39.961316, 116.491394)); OverlayOptions polygonOptions = new PolygonOptions().points(points).stroke(new Stroke(5, 0xAA00FF00)).fillColor(0xAAFFFF00); mBaiduMap.addOverlay(polygonOptions); ``` 2. 判断点是否在多边形内: ``` public static boolean isPointInPolygon(LatLng point, List<LatLng> polygon) { int intersectCount = 0; for (int j = 0; j < polygon.size() - 1; j++) { if (rayCastIntersect(point, polygon.get(j), polygon.get(j + 1))) { intersectCount++; } } return (intersectCount % 2) == 1; } public static boolean rayCastIntersect(LatLng point, LatLng p1, LatLng p2) { double px = point.longitude, py = point.latitude; double ax = p1.longitude, ay = p1.latitude; double bx = p2.longitude, by = p2.latitude; if (ay > by) { ax = p2.longitude; ay = p2.latitude; bx = p1.longitude; by = p1.latitude; } // alter longitude to cater for 180 degree crossings if (px < 0) { px += 360; } if (ax < 0) { ax += 360; } if (bx < 0) { bx += 360; } if (py == ay || py == by) py += 0.00000001; if ((py > by || py < ay) || (px > Math.max(ax, bx))) return false; if (px < Math.min(ax, bx)) return true; double red = (ax != bx) ? ((by - ay) / (bx - ax)) : Double.MAX_VALUE; double blue = (ax != px) ? ((py - ay) / (px - ax)) : Double.MAX_VALUE; return (blue >= red); } ``` 这样就能够实现自定义划分区域获取区域内的坐标点了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值