第8行: | 第8行: | ||
| width="90" | '''参考文档''' | | width="90" | '''参考文档''' | ||
|- | |- | ||
− | | | + | | Geocoder |
− | | | + | | gc.getLocation(point,function) |
− | | | + | | 获取行政区划信息 |
− | | | + | | 无 |
|- | |- | ||
− | | | + | | InfoWindow |
− | | | + | | map.openInfoWindow(infoWindow,point) |
− | | | + | | 信息窗口展示 |
− | | [[jspopularGL/guide/ | + | | [[jspopularGL/guide/infoWindow|信息窗口]] |
|} | |} | ||
− | </div></div><div class="header"><div class="active">核心代码</div></div><div class="pre-wrap"><div class="pre-wrap-w pre-wrap-w-and"><pre class="prettyprint prettyprinted pre-and"> | + | </div></div> |
+ | <div class="header"> | ||
+ | <div class="active">核心代码</div> | ||
+ | </div> | ||
+ | <div class="pre-wrap"> | ||
+ | <div class="pre-wrap-w pre-wrap-w-and"> | ||
+ | <pre class="prettyprint prettyprinted pre-and"> | ||
+ | map.addEventListener('click', function (e) { | ||
var point = new BMapGL.Point(e.latlng.lng, e.latlng.lat); | var point = new BMapGL.Point(e.latlng.lng, e.latlng.lat); | ||
var gc = new BMapGL.Geocoder(); | var gc = new BMapGL.Geocoder(); |
2020年10月9日 (五) 13:38的版本
行政区划归属获取
功能场景
该示例通过鼠标交互事件,介绍如何获行政区划的信息。
DEMO
https://mapopen-website-wiki.cdn.bcebos.com/wiki/android-loc-sdk/sdkgetAK.mov
获取行政区划归属信息示例
核心接口
类 | 接口 | 描述 | 参考文档 |
Geocoder | gc.getLocation(point,function) | 获取行政区划信息 | 无 |
InfoWindow | map.openInfoWindow(infoWindow,point) | 信息窗口展示 | 信息窗口 |
核心代码
map.addEventListener('click', function (e) { var point = new BMapGL.Point(e.latlng.lng, e.latlng.lat); var gc = new BMapGL.Geocoder(); gc.getLocation(point, function (rs) { var opts = { title: '行政区划归属', width: 220, height: 92 }; var infoStr = '<div>省:' + rs.addressComponents.province + '</div>' + '<div>市:' + rs.addressComponents.city + '</div>' + '<div>区:' + rs.addressComponents.district + '</div>'; var infoWindow = new BMapGL.InfoWindow(infoStr, opts); map.openInfoWindow(infoWindow, point); }); });
复制
深色
复制成功