简体   繁体   中英

WP8 Map Navigation

I want to create a simple navigation app for windows phone. I want it to navigate user to the provided address. I'm creating route, as it's described here: http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj244363%28v=vs.105%29.aspx#BKMK_showdirections But it's a static route and I want it to be updated with current user position. Currently I'm thinking about this solution:

On the Geolocator's event PositionChanged I'll calculate new route from current position:

void Instance_GeolocatorGeopositionReadingChanged(object sender, ReadingValueChanged<Geoposition> e)
    {
        RouteQuery query = new RouteQuery()
        {
            TravelMode = TravelMode.Driving,
            Waypoints = new List<GeoCoordinate>()
            {
                e.NewReading.Coordinate.ToGeoCordinate(),
                this.target 
            }
        };
        query.QueryCompleted += routeQuery_QueryCompleted;
        query.QueryAsync();
    }

But I'm not sure, if this is good a good approach, because in terms of use of MS's maps there is, that you may not: exceed 25000 routing and geo-coding requests within 24 hours by one application

And if app would recalculate route on every position changed, one long trip would exceed the limit. Is there a better approach?

Definetely you should not re-calculate the route all the time. Basically once you get your first route check the Route::Legs to see how the user is supposed to get to the destination, and then implement a logic for monitoring that user is staying on the selected route leg-by-leg.

And only if the user goes out from the route (for example, turns to wrong direction), then have the logic to then go and get new route, and start monitoring it again.

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