c# - Issue with drawing routes on Windows Phone 8.0 maps - 0x8004231C -
i want create app shows route location desired point. problem works (for locations route drawn) in cases error:
"system.runtime.interopservices.comexception (0x8004231c): excepion hresult: 0x8004231c.
in addition followed tutorial found here: https://msdn.microsoft.com/en-us/library/windows/apps/jj244363%28v=vs.105%29.aspx
here's code:
private async void getcoordinates() { // phone's current location. geolocator mygeolocator = new geolocator(); mygeolocator.desiredaccuracyinmeters = 5; geoposition mygeoposition = null; try { mygeoposition = await mygeolocator.getgeopositionasync(timespan.fromminutes(1), timespan.fromseconds(10)); mycoordinates.add(new geocoordinate(mygeoposition.coordinate.latitude, mygeoposition.coordinate.longitude)); mapka.center = new geocoordinate(mygeoposition.coordinate.latitude, mygeoposition.coordinate.longitude); } catch (unauthorizedaccessexception) { messagebox.show("location disabled in phone settings or capabilities not checked."); } catch (exception ex) { // else happened while acquiring location. messagebox.show(ex.message); } mygeocodequery = new geocodequery(); mygeocodequery.querycompleted += mygeocodequery_querycompleted; mygeocodequery.searchterm = txt1.text; mygeocodequery.geocoordinate = new geocoordinate(mygeoposition.coordinate.latitude, mygeoposition.coordinate.longitude); mygeocodequery.queryasync(); } void mygeocodequery_querycompleted(object sender, querycompletedeventargs<ilist<maplocation>> e) { if (e.error == null) { myquery = new routequery(); mycoordinates.add(e.result[0].geocoordinate); myquery.waypoints = mycoordinates; myquery.querycompleted += myquery_querycompleted; myquery.routeoptimization = routeoptimization.minimizedistance; myquery.queryasync(); mygeocodequery.dispose(); } else { messagebox.show(e.error.tostring()); } } void myquery_querycompleted(object sender, querycompletedeventargs<route> e) { if (e.error == null) { route myroute = e.result; maproute mymaproute = new maproute(myroute); mapka.addroute(mymaproute); mapka.setview(mymaproute.route.boundingbox); messagebox.show(mymaproute.route.lengthinmeters.tostring()); myquery.dispose(); } else { messagebox.show(e.error.tostring()); } }
maybe had similar problem , can help?
it works fine me:
geocoordinate myposition = null; maproute mymaproute = null; routequery route = null; private void getrouteto(geocoordinate myposition, geocoordinate destination) { if (mymaproute != null) { map.removeroute(mymaproute); mymaproute = null; route = null; } route = new routequery() { travelmode = travelmode.driving, waypoints = new list<geocoordinate>() { myposition, destination }, routeoptimization = routeoptimization.minimizetime }; route.querycompleted += routequery_querycompleted; route.queryasync(); } void routequery_querycompleted(object sender, querycompletedeventargs<route> e) { if (e.error == null) { route myroute = e.result; mymaproute = new maproute(myroute); map.addroute(mymaproute); route.dispose(); } }
Comments
Post a Comment