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.
Set global Windows Forms optionsIn Visual Studio, from the Tools menu, select Options. In the left pane of the Options dialog box, click Windows Forms Designer. In the right pane, under the Layout Settings heading, you can set the default grid settings for all the new forms you create.
Windows Forms contains a variety of controls that you can add to forms: controls that display text boxes, buttons, drop-down boxes, radio buttons, and even webpages. If an existing control doesn't meet your needs, Windows Forms also supports creating your own custom controls using the UserControl class.
AutoMapper in C# is a library used to map data from one object to another. It acts as a mapper between two objects and transforms one object type into another. It converts the input object of one type to the output object of another type until the latter type follows or maintains the conventions of AutoMapper.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With