首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Android/IOS中使用URI处理百度地图中的多个目的地

如何在Android/IOS中使用URI处理百度地图中的多个目的地
EN

Stack Overflow用户
提问于 2019-03-12 17:46:14
回答 2查看 402关注 0票数 0

我们正在整合百度地图,并希望在地图上显示多个停靠点(目的地)。我们浏览了百度地图(http://lbsyun.baidu.com/index.php?title=uri/api/android)的官方文档,发现了一个名为“viaPoints”的参数。根据文档,我们需要在URL键中传递JSON,但我们无法在viaPoints中附加JSON。

在android中,我们是这样传递的:

代码语言:javascript
复制
Intent i1 = new Intent();
i1.setData(Uri.parse("baidumap://map/direction?mode=driving&destination=上上&origin=西二旗&src=push&viaPoints={viaPoints:[{name:Beijing West Railway Station, lat:39.902463,lng:116.327737}]}"));
startActivity(i1);

我们希望实现多个目的地,如附图所示。

EN

回答 2

Stack Overflow用户

发布于 2019-03-12 17:52:23

虽然你提到的文档看起来是用中文写的,但我有个想法。

您没有使用双引号将数组viaPoints和JSON参数中的其他键括起来。

JSON需要采用以下格式

代码语言:javascript
复制
{
  "viaPoints": [
    {
      "name": "Beijing West Railway Station",
      "lat": 39.902463,
      "lng": 116.327737
    }]
}

尝尝这个

代码语言:javascript
复制
i1.setData(Uri.parse("baidumap://map/direction?mode=driving&destination=上上&origin=西二旗&src=push&viaPoints={\"viaPoints\":[{\"name\":\"Beijing West Railway Station\", \"lat\":39.902463,\"lng\":116.327737}]}"));
票数 0
EN

Stack Overflow用户

发布于 2019-03-12 18:07:46

代码语言:javascript
复制
   // Instantiates a new Polyline object and adds points to define a rectangle
PolylineOptions rectOptions = new PolylineOptions()
        .add(new LatLng(37.35, -122.0))
        .add(new LatLng(37.45, -122.0))  // North of the previous point, but at the same longitude
        .add(new LatLng(37.45, -122.2))  // Same latitude, and 30km to the west
        .add(new LatLng(37.35, -122.2))  // Same longitude, and 16km to the south
        .add(new LatLng(37.35, -122.0)); // Closes the polyline.

// Get back the mutable Polyline
Polyline polyline = myMap.addPolyline(rectOptions);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55118404

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档