Created GMapImage class, almost works...

Jun 30, 2010 at 7:38 PM
Edited Jun 30, 2010 at 7:39 PM

I wanted to make an overlay class which is an image (for example http://radar.weather.gov/ridge/Conus/RadarImg/latest_radaronly.gif) and it almost works. The problem is OnRender() is not called as often as I would expect. I'd expect it to be called everytime the map is zoomed or scrolled, but it is only called sometimes when the map is zoom or scrolled. No idea why only sometimes. 

Any ideas?

 

public class GMapImage : GMapMarker
{
		public Image image = null;
		GMap.NET.Point botleft;
		GMap.NET.Point topright;

		public GMapImage(GMap.NET.PointLatLng p)
			: base(p)
		{
		}

		public void Update(GMap.NET.Point botLeft, GMap.NET.Point topRight)
		{
			Console.WriteLine("Update!");
			botleft = botLeft;
			topright = topRight;
		}

		public override void OnRender(Graphics g)
		{
			Console.WriteLine("OnRender!");
			if (image == null)
				return;
			g.DrawImage(image, new Rectangle(botleft.X, topright.Y, topright.X - botleft.X, botleft.Y - topright.Y));
		}
}

 

Coordinator
Jun 30, 2010 at 7:49 PM

what do you mean?

Jun 30, 2010 at 8:13 PM

I'm not really sure I understand the question, what do I mean about what? Why is OnRender() not called when it needs to be?

GMapImage is like a GMapMarkerRect in the Demo project, except instead of a rectangle it displays an image. Not shown above is the assignment to the image member. 

Just like GMapMarkerRect, I add GMapImage to an GMapOverlay which is added to a class that inherits from GMapControl. It works, and I can zoom in a couple times and OnRender() is called and the image displays correctly. But zoom some more and OnRender() is not called. Image no longer displayed.

 

Coordinator
Jun 30, 2010 at 8:23 PM

it work, do you need a proof? ;}

Jun 30, 2010 at 8:42 PM

It does not work, so yes I need a proof. The proof should include zooming in all the way and re-centering the map on any clicked point.

Coordinator
Jun 30, 2010 at 8:45 PM

so how GMapMarkerGoogleGreen works?

Jun 30, 2010 at 8:54 PM

yes. I sure wish GMapImage worked too

Coordinator
Jun 30, 2010 at 8:59 PM

but i don't see any differences, it's just other image rendered in exact way

Jun 30, 2010 at 9:00 PM
Edited Jun 30, 2010 at 9:09 PM

How can I cause OnRender() to be called whenever I like? It has something to do with my image being very large.

Coordinator
Jun 30, 2010 at 9:04 PM

? its called automatically while invalidating map(on zoom, dragg)

Jun 30, 2010 at 9:11 PM

Below is my debug output during zoom-in operations. OnRender is called the first 2 times, but subsequent zoom operations produce no OnRender() calls.

OnRender!

OnRender!

Update!

Update!

Update!

Update!

Update!

Update!

Coordinator
Jun 30, 2010 at 9:16 PM

what Update means?

Jun 30, 2010 at 9:23 PM
Edited Jun 30, 2010 at 9:54 PM

I call Update when I am going to zoom (or scroll) the map. See code in first post.

If I recenter the map it OnRender() is called at first. But as I recenter to the right (moving the map left) at some point OnRender() is no longer called. What point? Not sure, about when more than 1/2 the image is off the screen. Then when I recenter to left (moving map right) it starts working again. 

Same thing with a small image, scrolling map causes image to appear (OnRender is called) and disappear (OnRender is not called).

Jun 30, 2010 at 10:01 PM
Edited Jun 30, 2010 at 10:10 PM

I added a method to GMapControl

 

public Graphics getGraphics()
{
	return this CreateGraphics();
}

 

and I call OnRender() myself when I call Update(). Now it almost works, but my Update() is too soon or something... I see my image, then it disappears.

Coordinator
Jun 30, 2010 at 10:07 PM

i still can't understand what's the problem ;} everything works, so can you zip your solution?, i'll fix it if it's possible

Jun 30, 2010 at 10:13 PM

Okay; my project is large. I will try to create a small project to reproduce the problem.

Jun 30, 2010 at 10:46 PM
Okay,

see sample project - gmail does not allow for zip files so I have renamed it.

After creating the project, click on the map to re-center. Notice weather overlay moves nicely for a while. As you click westward the USA moves to the right. When the USA is only showing the west coast the weather disappears. 

When you move the USA back to the middle of the form the weather re-appears. 

any idea why?

thanks for your help,
Gerry
Coordinator
Jul 1, 2010 at 5:35 AM

where do you put it? use skydrive/divshare/etc

Jul 1, 2010 at 7:00 PM
it was attached to the email. 


thanks,
Gerry


On Wed, Jun 30, 2010 at 10:35 PM, radioman <notifications@codeplex.com> wrote:

From: radioman

where do you put it? use skydrive/divshare/etc


Coordinator
Jul 1, 2010 at 8:42 PM

check the source, i've included Demo.Clouds ;}

Jul 1, 2010 at 9:37 PM

thanks radioman!

Coordinator
Jul 1, 2010 at 9:56 PM

cheers ;}