Android 使用路由和添加地图上的位置功能,它们是标准包的一部分吗?
我们需要知道可用于以下目的的API列表: 1-在地图上添加位置Android 使用路由和添加地图上的位置功能,它们是标准包的一部分吗?,android,ios,Android,Ios,我们需要知道可用于以下目的的API列表: 1-在地图上添加位置 2-使用路线功能,以便用户可以到达该地点(目的地)…我们还需要知道这些API的包是否…是,您肯定可以使用上述所有功能。您可以通过开发者android网站查阅此链接。是的,您肯定可以使用上述所有功能。您可以通过开发者android网站引用此链接。在ios中,您也可以使用本机Apple MapKit方法 要添加管脚,请执行以下操作: func映射视图(\mapView:MKMapView,viewforannotation:MKAnno
2-使用路线功能,以便用户可以到达该地点(目的地)…我们还需要知道这些API的包是否…是,您肯定可以使用上述所有功能。您可以通过开发者android网站查阅此链接。是的,您肯定可以使用上述所有功能。您可以通过开发者android网站引用此链接。在ios中,您也可以使用本机Apple MapKit方法 要添加管脚,请执行以下操作:
func映射视图(\mapView:MKMapView,viewforannotation:MKAnnotation)->MKAnnotationView?
对于创建路由,下面是一个示例代码:
let transportType: MKDirectionsTransportType = (transportType == .car) ? .walking : .automobile
let directionRequest = MKDirectionsRequest()
let sourcePLacemark = MKPlacemark(coordinate: (locationManager.location?.coordinate)!, addressDictionary: nil)
let destinationPlacemark = MKPlacemark(coordinate: (view.annotation?.coordinate)!, addressDictionary: nil)
directionRequest.source = MKMapItem(placemark: sourcePLacemark)
directionRequest.destination = MKMapItem(placemark: destinationPlacemark)
directionRequest.transportType = transportType
let directions = MKDirections(request: directionRequest)
directions.calculate { (response, error) in
guard let response = response else {
if let error = error {
print(error)
}
return
}
let route = response.routes.first
self.mapView.add((route?.polyline)!, level: .aboveRoads)
}
在ios中,您还可以使用原生的Apple MapKit方法来实现这一点 要添加管脚,请执行以下操作:
func映射视图(\mapView:MKMapView,viewforannotation:MKAnnotation)->MKAnnotationView?
对于创建路由,下面是一个示例代码:
let transportType: MKDirectionsTransportType = (transportType == .car) ? .walking : .automobile
let directionRequest = MKDirectionsRequest()
let sourcePLacemark = MKPlacemark(coordinate: (locationManager.location?.coordinate)!, addressDictionary: nil)
let destinationPlacemark = MKPlacemark(coordinate: (view.annotation?.coordinate)!, addressDictionary: nil)
directionRequest.source = MKMapItem(placemark: sourcePLacemark)
directionRequest.destination = MKMapItem(placemark: destinationPlacemark)
directionRequest.transportType = transportType
let directions = MKDirections(request: directionRequest)
directions.calculate { (response, error) in
guard let response = response else {
if let error = error {
print(error)
}
return
}
let route = response.routes.first
self.mapView.add((route?.polyline)!, level: .aboveRoads)
}
您可以使用google direction api和places api您可以使用google direction api和places api