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

发布于 2019-03-12 17:52:23
虽然你提到的文档看起来是用中文写的,但我有个想法。
您没有使用双引号将数组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-12 18:07:46
// 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);https://stackoverflow.com/questions/55118404
复制相似问题