0

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

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

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);

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

在此处输入图像描述

4

2 回答 2

0
   // 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);
于 2019-03-12T10:07:46.030 回答
0

尽管您提到的文档看起来在Cinees中,但有一个想法。

您没有viaPoints在 JSON 参数中的数组和其他键周围使用双引号。

JSON 需要是这种格式

{
  "viaPoints": [
    {
      "name": "Beijing West Railway Station",
      "lat": 39.902463,
      "lng": 116.327737
    }]
}

尝试这个

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}]}"));
于 2019-03-12T09:52:23.077 回答