问题描述
我需要在我的应用程序google maps中显示在Android上,并且还应该是规划两点之间的路线,并且需要设置旅行方式(步行,开车)。
我应该使用哪个包裹?
解决方法
该软件包为[nativescript-google-maps-sdk][1]
,但如果您确实想在自己的应用程序中显示路线,则上面引用的文档将非常相关。另外,您可以撰写并打开一个网址,该网址会打开默认的地图应用,其中包含路线/路线并在那里具有所有预期功能。为此,您可以使用nativescript-geolocation插件来获取当前位置,并使用utils.openUrl方法来打开组合的URL。您还需要使用https://github.com/nathanaela/nativescript-permissions
来处理请求权限。生成的代码可能类似于:
url = "https://www.google.com/maps/dir/?api=1&origin=" + loc.latitude + "," + loc.longitude + "&destination=" + addr.replace(/ /g,"+") + "";
utils.openUrl(url);
,
使用此API-https://developers.google.com/maps/documentation/directions/overview有助于获取路线和路线。