We help IT Professionals succeed at work.

Windows Universal App

341 Views
Last Modified: 2017-05-03
well it is supposed to be a map guide:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.Devices.Geolocation;
using Windows.Services.Maps;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409

namespace App50
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();

            _map.Tapped += _map_Tapped;
        }

        private void _map_Tapped(object sender, TappedRoutedEventArgs e)
        {
            BasicGeoposition b = new BasicGeoposition();

            b.Latitude = Convert.ToSingle(_latitude.Text);

            b.Longitude = Convert.ToSingle(_longitude.Text);

            Geopoint p = new Geopoint(b);

            MapLocationFinderResult r = MapLocationFinder.FindLocationsAtAsync(p).GetResults();

            foreach(var vari in r.Locations)
            {

                _result.Text = "Country:" + "" + vari.Address.Country + "" + "City:" + "" + vari.Address.Town;
            }
        }
    }
}
but it says"An System.Runtime.InteropServices.COMException appeared" and when I look where the problem is I found it in "MapLocationFinderResult r = MapLocationFinder.FindAtAsync(b).GetResults();"

please help me!!!
Comment
Watch Question

PawełI Design & Develop Software

Commented:
just off the top of my head did you add the location capability to your application in the app manifest?
Maps-manifest.png

Author

Commented:
don't understand

where can I find this?
PawełI Design & Develop Software

Commented:
double click the package.appmanifest file in your solution explorer
solution-explorer.png
then click the capabilities tab like above, again this is just off the top of my head

Author

Commented:
I ain't having Microsoft Visual Studio Blend

Author

Commented:
thanks

Author

Commented:
Look im having another for Windows.Data.Pdf

and every time I use PdfDocument class it shows me same thing

Author

Commented:
didn't work

Author

Commented:
"method called at unexpected time"

Author

Commented:
is this helpful?
PawełI Design & Develop Software

Commented:
you've got something very bizarre going on, try rebuilding a new project step by step and see where it goes wrong

Author

Commented:
:)

Author

Commented:
build engines all clear

Author

Commented:
did it and no result

Author

Commented:
heyy!!!!
I Design & Develop Software
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
PawełI Design & Develop Software

Commented:
just to make sure you did specify a mapservicetoken in your XAML right?

Author

Commented:
MapLocationFinderResult aint a MapLocationFinder.FindAtAsync(g).GetResults();???

Author

Commented:
oh oh nothing thanks!!!
PawełI Design & Develop Software

Commented:
so you're good? everything works?

Author

Commented:
wait...

Author

Commented:
yes

I corrected your await:

its before MapLocationFinder.FindAtAsync(g)

MapLocationFinderResult r = await MapLocationFinder.FindAtAsync(g);

4 later use!!

anyway thank u !!!!
PawełI Design & Develop Software

Commented:
no problem, one thing i should mention is that at the start of this thread i told you to go into the app manifest and turn on the location service, that's only needed if you where planing on using the device to figure out where the user is located. however if you're just going to be getting your location from the map tapped event and not the device; you may want to disable it.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.