Drawing using Canvas in GMap

Dec 14, 2009 at 4:53 PM

Hi,

First of all, congratulations on a great map engine!

We are currently trying to "draw" images (ellipse, line, polygons etc) "on" the map canvas. Now this is easy enough using the mapmarkers, but what we ideally require is to have the drawing shape at runtime as the mouse is being dragged. (Please have a look at this sample http://www.timfanelli.com/item/177, should explain it better)

We are making use of the WPF platform in this instance.

Has this been done?

I have toyed with the idea of having a transparent canvas overlayed on the gmap canvas, which will catch and handle the relevant mouse events - but introducing transparency brings together a new set of issues altogether.

Any ideas or guidelines in this will be greatly appreciated!

Cheers!

Coordinator
Dec 14, 2009 at 4:59 PM

yes, drawing polygons are already requested, i've found http://livegeometry.codeplex.com/ maybe there is change for integration

Dec 14, 2009 at 6:07 PM

In actual fact adding polygons is not a major coding effort.

I added polygon drawing to the winforms version in a few hours.

An example can be seen here, the pins can be added to or dragged to shape the polygon.

http://img191.imageshack.us/img191/6235/polygons.jpg

Please do not request code samples as the winforms control I am using has been modified quite a bit and is no longer source compatible with the one here.

Cheers

 

Coordinator
Dec 14, 2009 at 6:22 PM

you can try use internal map canvas: internal Canvas MapCanvas

Dec 14, 2009 at 6:43 PM

Hi Radioman,

Appreciate the quick response.

Busy taking a look at the live geometry solution.

My first take was to use the internal mapcanvas, but this (maybe in my ignorance) produced the following error when adding child objects : Cannot explicitly modify Children collection of Panel used as ItemsPanel for ItemsControl. ItemsControl generates child elements for Panel.

Am I missing something obvious?

Thanks all for the response thus far!

Cheers,

Zane

Coordinator
Dec 14, 2009 at 7:11 PM

well because it is itemcontrol, you just can't add directly any objects, must use .Markers/etc to add/remove items

Jan 4, 2010 at 7:52 AM

Hi Radioman,

 

Just a quick update on the drawing issue, managed to get it right using the internal mapcanvas, gmapmarker and then the subsequent handling of the mouse movement on the canvas when it is captured. (had to do a bit of work on the "localposition" in GMap as well)

Thanks for the responses! 

I am more than willing to make the code available to any party interested.

Regards,

Zane Strydom

 

Coordinator
Jan 4, 2010 at 7:59 AM

great! please share it by uploading a patch

Mar 18, 2010 at 4:22 PM

Hi Radioman, Zane,

I want users to create (by drawing) a region and save/open it. What Zane produced is probably very helpful for me.

Is this code made public?

Thanks,

Frank

 

Coordinator
Mar 18, 2010 at 7:54 PM

check in 'etc/codeplex not-applied patches.7z' it, if it's not there, you need contact him personally.

Nov 8, 2011 at 12:57 PM

Hello,

This is exactly what I too am looking for, does anyone have an example or have some of zane's code? I am too interested in drawing shapes with the click of the mouse and dragging.

 

Thanks,

Charles