ThinkGeo.com    |     Documentation    |     Premium Support

About Overlay Mouse events

Hello
I wrote a class that inherits from overlay, and I add UI elements to the OverlayCanvas of the class, but my UI elements are not responsive to mouse events, how can I respond to mouse events?

Hi Zhangming,

You forget to put the post into our sub-forum, but I guess your product is WPF edition from your text.

It looks you operate the element tree of our map but not via our API, that’s not our recommended solution, because it may cause some unexpected result.

Please upload a simple sample or paste your code so we can quickly look into your problem.

Regards,

Ethan

Hi @Ethan
In my demo you can see GisPoint.cs file you can see that I added tooltip and mousedown to the Ellipse element, but it didn’t work .
code: this.ellipse.ToolTip = “show tooltip test”;
this.ellipse.MouseDown += Ellipse_MouseDown;
private void Ellipse_MouseDown(object sender, MouseButtonEventArgs e)
{
MessageBox.Show(“this point is clicked”);
}
ThinkGeoGis.zip (3.0 MB)

Regards,

ZhangMing

Hi ZhangMing,

The workaround for your project should be set:
(base.OverlayCanvas.Parent as FrameworkElement).Parent.SetValue(Panel.ZIndexProperty, 903);

Please don’t put it in constructor.

But it would introduce some other issue.

And maybe you can try to inherit it from MarkerOverlay.

Regards,

Ethan

Thanks @Ethan
I’ve tried, it is work and I’ll try to inherit from MarkerOverlay.
ZhangMing

Hi ZhangMing,

Any question please let us know.

Regards,

Ethan

Hi @Ethan
I want to add a JPG or PNG image to the layer, and I use Jpeg2000RasterLayer. But I can’t add successfully, and the error I got was a general error in GDI +.
the code is:
Jpeg2000RasterLayer jpegLayer = new Jpeg2000RasterLayer(@“C:\Users\asus\Desktop\ThinkGeoGis\test.jpg”);
layerOverlay.Layers.Add(jpegLayer);

ZhangMing

Hi ZhangMing,

You should want to assign the extent to your image, so the map know where to draw it.

Jpeg2000RasterLayer jpegLayer = new Jpeg2000RasterLayer(“your path” , new RectangleShape( , , , ));

If you have a world file for the image, you can also pass in the world file.

Regards,

Ethan

Hi @Ethan
I like this to add Image,but can’t successfully.My program crashed.
Jpeg2000RasterLayer jpegLayer = new Jpeg2000RasterLayer(@“C:\Users\asus\Desktop\ThinkGeoGis\test.jpg”, MapControl.CurrentExtent);
Jpeg2000RasterLayer jpegLayer = new Jpeg2000RasterLayer(@“C:\Users\asus\Desktop\ThinkGeoGis\test.jpg”, worldLayer.ShapePathFilename);
layerOverlay.Layers.Add(jpegLayer);

Regards,
ZhangMing

Hi ZhangMing,

Please upload the simplest sample with your image, so we can see what’s the problem.

Regards,

Ethan

Hi Ethan
This is the picture I used.

Regards
ZhangMing

Hi ZhangMing,

I just found you are try to using Jpeg2000RasterLayer to render a jpg file.

JPEG2000 is a special format, it cannot be used to render the general image format.

Please download our package ThinkGeo.MapSuite.Layers.NativeImage, and render it like this:

        winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
        winformsMap1.CurrentExtent = new RectangleShape(-96.9055649057617, 32.9262169589844, -96.6515060678711, 32.7449425449219);


        NativeImageRasterLayer layer = new NativeImageRasterLayer(@"C:\Users\user\Desktop\test.jpg", winformsMap1.CurrentExtent);            
        LayerOverlay overlay = new LayerOverlay();
        overlay.Layers.Add(layer);

        winformsMap1.Overlays.Add(overlay);
        winformsMap1.Refresh();

It works well.

And please open a new topic when you have new question, and please put your post into our sub-forum, so we can know which version you are using.

Regards,

Ethan

Hi Ethan
thanks a lot. i try this way and work well.

Regards

ZhangMing

Hi ZhangMing,

Any question please let us know.

Regards,

Ethan