APP<\/a>\u4e3a\u5730\u56fe\u7684\u663e\u793a\u533a\u57df\u3002<\/p>\n\u56db\u3001\u5b9e\u73b0\u5b9a\u4f4d\u529f\u80fd<\/p>\n
1. \u5bfc\u5165\u5b9a\u4f4d\u6240\u9700\u7684\u7c7b\u5e93\uff0c\u6839\u636e\u4e0d\u540c\u5e73\u53f0\u8fdb\u884c\u5f15\u5165\u3002\u4f8b\u5982\uff0c\u5728Android\u5e73\u53f0\uff0c\u9700\u8981\u5f15\u5165TencentLocation\u548cTencentLocationListener\u3002<\/p>\n
2. \u5728MapActivity\uff08\u6216MapViewController\uff09\u4e2d\u521b\u5efa\u4e00\u4e2a\u5b9a\u4f4d\u8bf7\u6c42\u5bf9\u8c61\uff0c\u914d\u7f6e\u76f8\u5173\u53c2\u6570\uff0c\u5982\u5b9a\u4f4d\u6a21\u5f0f\u3001\u8bf7\u6c42\u95f4\u9694\u7b49\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
“`<\/p>\n
TencentLocationRequest request = TencentLocationRequest.create();<\/p>\n
request.setRequestLevel(TencentLocationRequest.REQUEST_LEVEL_NAME);<\/p>\n
request.setInterval(5000);<\/p>\n
“`<\/p>\n
3. \u521b\u5efa\u4e00\u4e2a\u5b9a\u4f4d\u7ed3\u679c\u76d1\u542c\u5bf9\u8c61\uff0c\u5b9e\u73b0\u76f8\u5173\u56de\u8c03\u65b9\u6cd5\u3002\u5f53\u5b9a\u4f4d\u7ed3\u679c\u8fd4\u56de\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u65b0MapView\u63a7\u4ef6\u7684\u4e2d\u5fc3\u70b9\u548c\u6bd4\u4f8b\u5c3a\uff0c\u4ee5\u4fbf\u5c06\u89c6\u89d2\u79fb\u52a8\u5230\u5f53\u524d\u4f4d\u7f6e\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
“`<\/p>\n
TencentLocationListener locationListener = new TencentLocationListener() {<\/p>\n
@Override<\/p>\n
public void onLocationChanged(TencentLocation location, int error, String reason) {<\/p>\n
if (error == TencentLocation.ERROR_OK) {<\/p>\n
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());<\/p>\n
mapView.getMap().setCenter(latLng);<\/p>\n
mapView.getMap().setZoom(15);<\/p>\n
} else {<\/p>\n
Toast.makeText(MapActivity.this, “\u5b9a\u4f4d\u5931\u8d25\uff0c\u9519\u8bef\u7801\uff1a” + error + “\uff0c\u539f\u56e0\uff1a” + reason, Toast.LENGTH_SHORT).show();<\/p>\n
}<\/p>\n
}<\/p>\n
@Override<\/p>\n
public void onStatusUpdate(String name, int status, String desc) {<\/p>\n
\/\/ \u6682\u4e0d\u5904\u7406<\/p>\n
}<\/p>\n
};<\/p>\n
“`<\/p>\n
4. \u5728MapActivity\uff08\u6216MapViewController\uff09\u7684\u751f\u547d\u5468\u671f\u65b9\u6cd5\u4e2d\u5f00\u59cb\u6216\u505c\u6b62\u5b9a\u4f4d\u3002\u4f8b\u5982\uff0c\u5728onResume\u65b9\u6cd5\u4e2d\u5f00\u59cb\u5b9a\u4f4d\uff0c\u5728onPause\u65b9\u6cd5\u4e2d\u505c\u6b62\u5b9a\u4f4d\u3002<\/p>\n
\u4e94\u3001\u5b9e\u73b0\u5bfc\u822a\u529f\u80fd<\/p>\n
1. \u521b\u5efa\u4e00\u4e2a\u5168\u5c40\u7684\u8def\u5f84\u89c4\u5212\u5bf9\u8c61\uff0c\u4f8b\u5982\u5728Android\u5e73\u53f0\u53ef\u4ee5\u4f7f\u7528TencentSearch\u7c7b\u3002<\/p>\n
2. \u4e3aMapView\u63a7\u4ef6\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\u3002\u5f53\u7528\u6237\u5728\u5730\u56fe\u4e0a\u70b9\u51fb\u4e00\u4e2a\u4f4d\u7f6e\u65f6\uff0c\u8c03\u7528\u8def\u5f84\u89c4\u5212\u63a5\u53e3\uff0c\u83b7\u53d6\u4ece\u5f53\u524d\u4f4d\u7f6e\u5230\u70b9\u51fb\u4f4d\u7f6e\u7684\u8def\u7ebf\u4fe1\u606f\u3002<\/p>\n
3. \u8def\u7ebf\u89c4\u5212\u7ed3\u679c\u8fd4\u56de\u540e\uff0c\u6839\u636e\u8fd4\u56de\u7684\u8def\u7ebf\u4fe1\u606f\uff0c\u5728MapView\u63a7\u4ef6\u4e0a\u7ed8<\/p>\n
<\/figure>\n<\/p>\n\u5236\u5bfc\u822a\u8def\u7ebf\u3002<\/p>\n
\u516d\u3001\u5c0f\u7ed3<\/p>\n
\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6211\u4eec\u6210\u529f\u5730\u5236\u4f5c\u4e86\u4e00\u4e2a\u5177\u6709\u5b9a\u4f4d\u548c\u5bfc\u822a\u529f\u80fd\u7684App\u3002\u817e\u8baf\u5730\u56feSDK\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5730\u56fe\u670d\u52a1\uff0c\u8fd9\u91cc\u4ec5\u4ecb\u7ecd\u4e86\u5176\u4e2d\u7684\u90e8\u5206\u529f\u80fd\uff0c\u66f4\u591a\u529f\u80fd\u7b49\u5f85\u5927\u5bb6\u6765\u6316\u6398\u548c\u5b9e\u8df5\u3002\u5e0c\u671b\u672c\u5b9e\u6218\u6559\u7a0b\u80fd\u4e3a\u5927\u5bb6\u5e26\u6765\u4e00\u4e9b\u542f\u793a\u548c\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
app\u5f00\u53d1sdk\u5b9e\u6218\u6848\u4f8b\uff1a\u4f7f\u7528\u817e\u8baf\u5730\u56feSDK\u5236\u4f5c\u4e00\u4e2a\u5b9a\u4f4d\u548c\u5bfc\u822a\u7684App\u8fd1\u5e74\u6765\uff0c\u968f\u7740\u624b\u673a\u667a\u80fd\u5316\u548c\u79fb\u52a8\u4e92\u8054\u7f51\u7684\u53d1\u5c55\uff0c\u79fb\u52a8App\u5df2\u7ecf\u6210\u4e3a\u6211\u4eec\u65e5\u5e38\u751f\u6d3b\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002\u4f5c\u4e3a\u4e00\u4e2a\u7f51\u7ad9\u535a\u4e3b\uff0c\u6211\u7ecf\u5e38\u9700\u8981\u7ed9\u5927\u5bb6\u8bb2\u89e3<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[171,3944,1753,2190,3945],"topic":[],"class_list":["post-1835","post","type-post","status-publish","format-standard","hentry","category-kaifaapp","tag-171","tag-app","tag-1753","tag-2190"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/1835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=1835"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/1835\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=1835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=1835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=1835"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=1835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}