Display a map in a Windows Form app
Question
I built a Winform app several months ago that schedules appointments for repair techs. I'd like to update the app by adding a map for the customer's address on the customer form, and then print that map on the report the techs take when they leave the office.
I've been looking around but I haven't found a good solution for this yet.
I currently have an address for the customer. What I'd like to do is submit the address to one of the popular online map sites and get a minimap of the locale. I can almost do this with Google maps using their embedded link feature. I can get the following HTML after adding an address to their website:
<iframe width="300" height="300" frameborder="0" scrolling="no"
marginheight="0" marginwidth="0"
src="http://maps.google.com/maps?hl=en&ie=UTF8&t=h&g=1193+Presque+Isle+Dr,+Port+Charlotte,+FL+33952&s=AARTsJqsWtjYwJ7ucpVS6UU2EInkRk6JLA&ll=27.012108,-82.087955&spn=0.005735,0.006437&z=16&output=embed">
</iframe>
My first plan was to simply parse this HTML and insert whichever customer's address was needed in place this address, then show the result in a browser object on the form. However, if I change the address in the above iframe Google gives me a "Your client does not have permission to get URL ..." message.
I have no preference on which map service I ultimately use, the important thing is that the solution can't have an associated expenses and its usable from Windows forms.
Anyone got an ideas/recommendations/resources on how to tackle this?
Results:
I ended up using the control found here. I find it an "okay" solution... it's tedious to get working as the code does not work as-is. I'm pretty stunned to find that none of the popular map APIs support winforms.
Solution
Both Google Maps and Live Maps have a public api.
Since you are doing winforms I'd probably use live maps.
http://dev.live.com/VirtualEarth/
There are a few examples on CodePlex.
http://codeplex.com/Project/ProjectDirectory.aspx?TagName=Virtual%20Earth
OTHER TIPS
There is some example code for developing a map viewer control (NB: I doubt this is strictly within their licence)
Otherwise, depending on your budget, you could use the MapPoint ActiveX control
Just use the value inside the src="" as the location for a WebBrowser control directly, without the IFRAME.
OR
Build a minimal html document wrapping the IFRAME, write it out to a MemoryStream, re-seek it back to the start, and use the MemoryStream to set the WebBrowser control's DocumentStream property.
PW