WebView use targeting in windows8.1 app

Source: Internet
Author: User

windows8.1 the WebView of the Web page there is no way to directly locate the more difficult to locate a long time to find a viable way

That is to get the location information through the background code and then invoke the JS method of obtaining location information in the page to pass the latitude and longitude of the location information to the Web page and load the location information in the Web page

The code is as follows:

Async voidwebview_navigationcompleted (webView sender, Webviewnavigationcompletedeventargs args) {Geolocator Geolocator /c2>=NewGeolocator (); Geoposition POS=awaitGeolocator.        Getgeopositionasync (); Geopoint POI=Pos.        Coordinate.point; varLat = poi. Position.latitude;//Latitude        varLon = POI. Position.longitude;//Longitudestring[] Loc={lon. ToString (), lat.        ToString ()}; awaitWebview.invokescriptasync ("Getloc", loc); }

There is an asynchronous Call WebView Web page JS method Getloc method Invokescriptasync can only be called in such a way on the WebView page to get location information

The JS method of the webpage is as follows:

function Getloc (Lon,lat)

{...}

Source: http://blogs.msdn.com/b/hanxia/archive/2013/10/01/windows-store-app.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.