-1
私は自分のUIにマップを含めて、デバイスの現在の位置から場所(レストランなど)までのルートを表示したいと考えています。どうやってやるの?マップコントロールにルートを描画するにはどうすればよいですか?
私は自分のUIにマップを含めて、デバイスの現在の位置から場所(レストランなど)までのルートを表示したいと考えています。どうやってやるの?マップコントロールにルートを描画するにはどうすればよいですか?
私はどのような技術を見ているのか分かりませんが、Windows上でそのようなことが必要な場合に備えて - UWPプラットフォームはルートを計算し、それを地図上にプロットする方法を提供します。
MapControl
とMapRouteFinder
は、開始GPS位置から終了GPS位置までのルートを計算する必要があります。結果からに追加できるMapRouteView
を作成することができます。 appmanifest
のLocation
機能も確認してください。あなたは次のようにすることができます:
// get the user's consent to determine the location
var status = await Geolocator.RequestAccessAsync();
if (status == GeolocationAccessStatus.Allowed)
{
// get the current position
Geolocator locator = new Geolocator() { DesiredAccuracy = PositionAccuracy.High };
Geoposition pos = await locator.GetGeopositionAsync();
BasicGeoposition current = new BasicGeoposition()
{ Latitude = pos.Coordinate.Latitude,
Longitude = pos.Coordinate.Longitude };
// set the lat/long of the restaurant
BasicGeoposition restaurant = new BasicGeoposition()
{ Latitude = 51.91997, Longitude = 4.486515 };
// get the driving route
MapRouteFinderResult route =
await MapRouteFinder.GetDrivingRouteAsync(new Geopoint(current),
new Geopoint(restaurant),
MapRouteOptimization.Time,
MapRouteRestrictions.None);
// get the view and add it to the map
MapRouteView routeView = new MapRouteView(route.Route);
routeView.RouteColor = Windows.UI.Colors.Red;
TheMap.Routes.Add(routeView);
// change the view of the map to see the complete route
await TheMap.TrySetViewBoundsAsync(route.Route.BoundingBox,
null, MapAnimationKind.Default);
}
あなたが試したことを共有してください – cavpollo
どのような地図がありますか?何をやっているの? iOS?アンドロイド? HTML Webページ?アップルウォッチ?具体的にしてください。 – Pang