Marcus
Marcus

Reputation: 116

Can Embedded Bing Map(Javascript) Send Data to a C# UI?

So I have a UI using XAML and I was thinking about having an embedded Bing Map, or maybe Google Map I'm not sure. It's possible to create an interactive map on the UI, but I need to be able to click pushpins and retrieve data which doesn't seem to be possible without Javascript, so I was wondering if the UI could open up an embedded map, which can easily have pushpin events(such as detecting clicks), and send the data from that pin back to the UI?

Upvotes: 1

Views: 147

Answers (1)

rbrundritt
rbrundritt

Reputation: 17954

Bing Maps has two different map controls that can be used in native .NET applications. So no need to embed a JavaScript map.

There is the Windows UWP map SDK that can be used in Windows apps, and in WPF apps via a XAML island. Here are some useful resources:

There is also an older WPF SDK that has fewer capabilities than the UWP SDK. It is generally recommended to use the UWP map control, but if you want to use this, here are the details: https://learn.microsoft.com/en-us/previous-versions/bing/wpf-control/hh750210(v%3dmsdn.10)

If you really want to embed a JavaScript map into a .NET app and be able to communicate between the two, it can be done. To do that you need to embed a web browser control into your .NET app and then us interop functions to send messages back and forth. This takes a decent amount of work to get working well. Note that if you use the built in .NET browser you cannot float XAML elements above the browser/map (this has been an issue for over a decade). If you embed the chrome browser it is possible to modify it so you can float XAML elements over the browser, but this also makes your app significantly larger.

Upvotes: 2

Related Questions