简体   繁体   中英

How to draw a route between two points(annotations) in Swift?

我想问问是否有人可以帮我一些代码...我不知道如何在Swift中的地图中创建路线,我只能在两个注解之间绘制一条折线,但它不可行我如何在地图上连接两个注释?但在道路上连接它们...所有这些都是为了游览公共汽车。有人可以帮我在Swift中向我展示此代码吗?

In order to trace a road like this, you will need data for the road geometry, but none of Apple's APIs provide this info. You will need to find your own source of geo data that both 1) provides point-by-point info for these routes as well as 2) matches the paths drawn in Apple Maps so that you trace lines up properly.

This is not a trivial problem. It's not likely to be done well using just Apple technology.

One way you could accomplish this is:

  1. Use an alternate, open source of data such as OpenStreetMap .

  2. Use a rendering library that draws such data for its basemap, such as Mapbox .

  3. Combine the OSM data-based base map with individual route OSM-based data such as from the Mapbox Directions API .

The bottom line is that since Apple's maps data is closed, you can't guarantee that anything you draw on top of it is an exact matchup. You need rendering and routing data to be from the same source.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM