Windows 8 Location-aware Navigation Application

Few years ago, back in 2008, when Windows 7 M3 (pre-beta) was released at Microsoft PDC 2008 conference (which I was proud attendee of), I wrote a sample Windows 7 Location-aware Navigation Application, which I then published to MSDN Code Gallery here.

It required me to:

  1. Install Windows 7 M3 + all Dev Tools
  2. Install and use Virtual Earth 3D (which later transformed into Bing Maps 3D, and then discontinued),
  3. Create new WPF 4 App
  4. use Windows 7 Integration Library that provided me access to Windows 7 Sensor and Location Platform – LocationProvider,
  5. use new WPF Ribbon control,
  6. I also had specific GPS device with GPS driver,
  7. use Windows 7 Integration Library to include basic multi-touch handling (zoom, panning was provided by OS),
  8. Combine all of that stuff together

All of these things were like experiments. Now, 3 years after that, and after epochal BUILD conference (that I wasn’t proud attendee of, though), I‘ve decided to repeat that experiment and look what it will take for me to write a Windows 8 Location-aware Navigation Application.

Well, it required a few things:

  1. Install Windows 8 Developer Preview with Apps & Dev Tools (x64)
  2. Install recently released Bing Maps WPF Control
  3. Create new WPF 4.5 App
  4. Reference the Bing Maps Control + get API Key for it
  5. Reference Windows.Devices.Geolocation.winmd (and few other WinRT WinMD files) (yes, you can do that!)
  6. Use Async access to Geolocation provider (like in Geolocation sample for WinRT, but make it optimized for WPF)
  7. Voila!

In this case, I didn’t use any Ribbon control, well, but, most important, I didn’t have to write up any multi-touch UI handling, it’s all done as magic for you in the Bing Maps WPF Control! You don’t need any specific Geolocation Sensor, Windows 8 has it’s own based on WiFi and IP for you, built-in!

Well, here’s a really short video showing the app, it’s as simple as that, yes Smile

Windows 8 Location-aware Navigation Application

UPDATE: And here you can grab it for your reference!

Advertisements

4 thoughts on “Windows 8 Location-aware Navigation Application

  1. Great example!!!
    But, could you give me advice, why this error occurs during build:

    Error 1 Property, indexer, or event ‘Windows.Devices.Geolocation.Geolocator.PositionChanged’ is not supported by the language; try directly calling accessor methods ‘Windows.Devices.Geolocation.Geolocator.add_PositionChanged(Windows.Foundation.TypedEventHandler)’ or ‘Windows.Devices.Geolocation.Geolocator.remove_PositionChanged(System.Runtime.InteropServices.WindowsRuntime.EventRegistrationToken)’ C:\Shared\Location Aware Navigation Using Windows 8\C#\WpfApplication1\MainWindow.xaml.cs 103 23 Win8LocA

    • Glad you found it useful. This code is written against Windows 8 Developer Preview, to get it working in Consumer Preview you need to:

      1) Change Target Framework to .NET 4.5
      2) Add reference to System.Runtime
      3) Add reference to System.Runtime.InteropServices.WindowsRuntime
      4) change code in this method:

      private void ToggleSwitch_Unchecked(object sender, RoutedEventArgs e)
      {
      if (m_geo != null)
      {
      m_geo.PositionChanged -= this.m_geo_PositionChanged;
      }
      }

      And it will work.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s