Link to home
Start Free TrialLog in
Avatar of spen_lang
spen_lang

asked on

VB NET Windows Application with Maps

Hi,

I would like some advice on creating a windows application that includes Maps where users can search for locations and generate directions between locations.

Currently I have created the app with a web browser that points to Google maps where the user can then enter the information required. However, this also includes all the extras that comes with the website, which I don't really want.

The next approach could be to add a mapping API, preferably Google but I need it to be free... Is this possible? If so how should I start.

The app that I am creating is for internal business use, for basically locking down a PC so the users can only use the mapping website.

Thanks, Greg
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

We can use below..Google API  ...you can get upto 25k maps per day.
you also have to register for it to get the key.

https://www.codeproject.com/Tips/889136/Csharp-Google-Maps-in-WinForm-with-WebBrowser-and

you can convert the c# above from below to VB.NET

http://converter.telerik.com/
Avatar of spen_lang
spen_lang

ASKER

OK thanks, I thought it was only free for Android Apps?
See the entire collection from google.

https://developers.google.com/places/android-api/

Google Maps Android API
Google Maps Directions API
Google Maps Distance Matrix API
SOLUTION
Avatar of Thierry van Mourik
Thierry van Mourik
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Snarf0001, do you have any examples or places to start?
Best place would be here to start:
https://msdn.microsoft.com/en-us/library/hh745791.aspx

Runs you through getting a key, what you need, and creating the first app.
Links to full development resources / docs as well.
Hi, how do I add this to an existing Windows App? I have tried adding a new User Control (WPF) but when I then try to add teh control to a new Windows Form in my existing app I get teh error: "Value cannot be null. Parameter name: objectType".

<UserControl x:Name="BingMaps" x:Class="BingMaps"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:KioskMode"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <m:Map CredentialsProvider="MyKey" Mode="AerialWithLabels" />
    </Grid>
</UserControl>

Open in new window

How did you add the control, did you try to add it directly or through an ElementHost?
If you can post more code I can try to see what the problem is, just made a quick and dirty WinForm version myself and it worked properly, so would need more details from you.

Even stacktrace and inner exceptions from the error you mentioned would help.
Thank you, I have just this moment worked it out, I forgot to rebuild my app before adding the WPF ElementHost and therefore it was still referencing the older WPF control I created.
How would I do this within the control?

 Public Sub New()
        InitializeComponent()
        'Set the map mode to Aerial with labels
        myMap.Mode = New AerialMode(True)
    End Sub
Exactly like you have it should work.

Both within the xaml like you had earlier, "<m:Map CredentialsProvider="MyKey" Mode="AerialWithLabels" />", as well as the code snippet directly above "myMap.Mode = New AerialMode(True)".

What's not working?
Is It possible to add the "directions" feature to the map control?

For example I would like users to be able to search the map for places and get direction between two locations...

Thanks, Greg
Yes, you need to use the "Routes API" for that.
https://msdn.microsoft.com/en-us/library/ff701705.aspx

Once you get the data, you can draw on the map with Polylines, and display the text steps however you see fit.

Link with a bit more detail (for silverlight, but basically the same thing):
https://social.msdn.microsoft.com/Forums/en-US/d7b0b272-35f3-4724-8546-dce9bd8b1e3d/wpf-bing-map-control-how-to-draw-route-lines?forum=bingmapssilverlightwpfcontrols


One important thing to note, when you're using the rest services, make sure you initialize the call with the map's SESSION key as outlined here (Making use of Sessions):
https://msdn.microsoft.com/en-us/library/jj819168.aspx

Otherwise you'll incur more instance charges since it thinks each one is a new request.
Both comments helped