How to load Google Maps in wpf window? - wpf

Is it possible to load Google Maps in wpf window? If yes how can i do this?
I'm using visual studio-2010 and DevExpress tool.
This code i found from DevExpress official site for openstreetmaps.
const string roadUrlTemplate = #"http://{subdomain}.tile.openstreetmap.org/{tileLevel}/{tileX}/{tileY}.png";

An easy way is to use the WebBrowser control.
In XAML add:
<WebBrowser x:Name="wbMaps" Source="https://www.google.com/maps"/>

If you are not limited to using Google Maps then take a look at the Bing Maps WPF control for a truly native WPF map solution:
http://msdn.microsoft.com/en-us/library/hh750210.aspx
If you need to use Google Maps you can of course use a web browser control and create an interlop to communicate between C# and JavaScript however if you want a native WPF solution then take a look at some open source solutions like the following:
http://greatmaps.codeplex.com/
https://github.com/ericnewton76/gmaps-api-net

Related

How to integrate OpenLayers in WPF application

I've already succeed to use Open Layers library in ASP.NET application but i don't succeed to integrate it in W PF Application and i don't found examples.
Is it possible? how can i load the map and interact? Is anyone have link or examples?
Best Regards.
It is possible via the WebBrowser Class: WebBrowser Class

Panning web map not working in WPF WebBrowers. Works in Internet Explorer

We have an intranet web GIS application which I am trying to embed in a WPF application using a WebBrowser control. The application is a proprietary solution from a third party vendor over which I have no control - it works very similar to Google Maps. On my desktop I have Internet Explorer 11 installed, and in Internet Explorer the web GIS works fine. When embedded in a WebBrowser control on a WPF form (.NET 4.5, VS2012) the map loads and will zoom with a roll of the mouse wheel, but will not pan when I try to drag it.
The WPF view is as simple as can be:
<Grid>
<WebBrowser x:Name="TestWebBrowser" />
</Grid>
The code-behind is equally simple:
public MainWindow()
{
InitializeComponent();
this.TestWebBrowser.Navigate("http://myserver/map.aspx");
}
I've tried setting the registry key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\myapp.exe (and the .vshost.exe variant) to various values without success.
If I change the URL to http://maps.google.com, I can pan the Google map, so I know the WebBrowser isn't fundamentally incapable of allowing drag events in my current configuration, but I can't change the source code of the web application itself.
Any ideas?
If you're running a 32bit app you need to set the registry key in Wow6432Node node.
So your key will look like:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\myapp.exe

Simple integration of Bing Maps into WPF application page

How would I go about integrating Bing Maps into a page or frame in my WPF application? I have found a lot of resources for Bing Maps development, but I don't need to develop with Bing Maps, just add the actual thing into my application without hyper-linking out to the website.
Windows 8 applications do this with "contracts" with other metro apps but I do not see a similar functionality with WPF applications.
Thank you!
Just go here and download the control :)
http://msdn.microsoft.com/en-us/library/hh750210.aspx
The control is in the "Bing Maps WPF Control SDK"
If i remember correctly you will need to register for an api key.
UPDATE:
to get the api key you have to register here https://www.bingmapsportal.com/
This was a lot easier than I expected, #Tjofras had a correct answer but here is some more elaboration:
1) Get a Bing Maps developer key for free here - https://www.bingmapsportal.com/
There is a trial version that gives you all the features, but for a limited time and there is a basic version that is free but has limited features.
2) Create a project in Visual Studio for Desktop
3) Check out this article for step-by-step instructions and the exact lines of code to integrate it into your project.
This line goes at the top of your MainWindow.xaml page :
xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
Add the map into your existing grid with your developer key, initial latitude and longitude values, and an initial zoom level with the tags:
m:Map object
CredentialsProvider tag (your developer license code)
Center tag (initial latitude and longtitude)
ZoomLevel tag (how zoomed in you are)
Browse the API's and make your application awesome!

How to cast from Windows.UI.Xaml.UIElement to System.Windows.Controls.UIElement

I'm trying to create a new UI for an app I developed for the Windows Store using the Windows Runtime API. This new client is going to be a WPF Desktop App. I'm trying to reuse as much code as I can but I'm facing several issues.
Fortunately there's a way to use WinRT in a WPF Desktop app (see this and this)
Now I'm blocked by the following issue:
The MediaCapture class has a method to start the preview of a device, after I've started the preview I can create a CaptureElement to display the preview.
CaptureElement is part of Windows.UI.Xaml.Controls and cannot be used in containers from System.Windows.Controls in which the WPF UI is built.
Am I going anywhere with this approach? what would you recommend? How can I display the preview of a device in the WPF app?
Thanks in advance
CaptureElement can't be used in desktop applications - the documentation says "[Windows Store apps only]". In general - the UI controls from WPF and WinRT/XAML can't be used outside of their respective domains (desktop/immersive UI). In a WPF app you need to use WPF controls - e.g. DirectShow for camera capture,

Silverlight Bing map question

I am planning to use Silverlight control for bing map. It will be used in a ASP.Net website.
Note: I am new to Silverlight and Bing map.
How the Silverlight bing map control will behave? Will the bing map service be called from the client browser or the web server?
Is there any architecture diagram related to this?
Please help.
Thanks
Lijo Cheeran Joseph
A good place to start is on the following link:
http://www.microsoft.com/maps/product/faq.aspx
I do not know about any architecture diagrams. With the Silverlight control (the preferred control at this point, over the old AJAX control), the map service is called from the client browser...it is called from within the Silverlight application that hosts the map control, which like all Silverlight applications, runs exclusively on the client.
You could make calls to the Bing web services server-side, then use that data in some way, but if you're going after an interactive map, you will want the Silverlight control.

Resources