Using ASP.NET, The latest changeset of SharpMap ( 19234 ) and GdalRasterLayer..
I have a map rendered, and have added extra points in another layer using the following code:
SharpMap.Layers.VectorLayer pointsOfInterestLayer = new SharpMap.Layers.VectorLayer("PointsOfInterest");
System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry> geomCol = new System.Collections.ObjectModel.Collection<SharpMap.Geometries.Geometry>();
pointsOfInterestLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomCol);
pointsOfInterestLayer.Style.Symbol = new Bitmap(Server.MapPath(@"~/App_data/icon.bmp"));
This works fine, I am looking to know however if there is a built-in way of detecting clicks (or hovers) to the points of interest on the map, ideally to display a ToolTip, but the main thing is detecting the click and knowing which item was clicked.
I can obviously implement this a primitive way (detect the click, transform the image co-ordinates into map co-ordinates, if they are within <icon-size> of a point then that point was clicked) but must be an easier way, no?
All SharpMap does is returning a "dumb" bitmap image. You have to write your own code that displays the bitmap and listens for click events. So unfortunately you need to do the "primitive" way. There are helper methods for converting from screen coordinates though.
There are a few sample controls in the SharpMap.UI namespace where you can see how it could be done, but these are just samples to help people get started. SharpMap's main focus is an engine for rendering maps, and not the UI layer of things.
The primitive way is not too much of a bind, fairly easy to do, I just didn't want to waste my time if there was a way to do it.
Thanks again, and keep up the good work. If you have a moment, please consider taking a look at my other post - http://www.codeplex.com/SharpMap/Thread/View.aspx?ThreadId=8036 - (it's really driving me up the wall!)
Thanks fatboy. As I understand, you are not using the ajax version. You put the map pimage on an image button. And the image button has the onclick event. But ajaxmap doesn't have one!