Detecting a click / displaying ToolTips
来源:互联网 发布:淘宝tm标 r标什么意思 编辑:程序博客网 时间:2024/04/29 23:52
Detecting a click / displaying ToolTips
Tags: General Topics
Tags: General Topics
fatboyjim
Mar 11 2007 at 6:21 AM
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>();
geomCol.Add(new SharpMap.Geometries.Point ( 530000, 230000 ) );
pointsOfInterestLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomCol);
pointsOfInterestLayer.Style.Symbol = new Bitmap(Server.MapPath(@"~/App_data/icon.bmp"));
map.Layers.Add(pointsOfInterestLayer);
map.ZoomToExtents();
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?
Thanks again for your time
Jim
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>();
geomCol.Add(new SharpMap.Geometries.Point ( 530000, 230000 ) );
pointsOfInterestLayer.DataSource = new SharpMap.Data.Providers.GeometryProvider(geomCol);
pointsOfInterestLayer.Style.Symbol = new Bitmap(Server.MapPath(@"~/App_data/icon.bmp"));
map.Layers.Add(pointsOfInterestLayer);
map.ZoomToExtents();
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?
Thanks again for your time
Jim
Odegaard
Mar 11 2007 at 6:56 PM
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.
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.
fatboyjim
Mar 12 2007 at 1:17 AM
Thanks for the message, it was worth a try! :)
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!)
Jim
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!)
Jim
Vedat
Mar 12 2007 at 6:01 AM
Hi fatboyjim,
How did you manage to detect mouse clicks? Did you use javascript or C# code to handle mouse clicks? I would be happy If you share this. Thanks.
How did you manage to detect mouse clicks? Did you use javascript or C# code to handle mouse clicks? I would be happy If you share this. Thanks.
fatboyjim
Mar 12 2007 at 8:01 AM
Hi Vedat,
Detecting mouse clicks was easy. The following works for me to pan around a map:
ASP.NET code:
<asp:ImageButton Width="1000" Height="700" ID="imgMap" runat="server" OnClick="imgMap_Click" style="border: 1px solid #000;" />
C# code:
protected void imgMap_Click(object sender, ImageClickEventArgs e)
{
myMap.Center = SharpMap.Utilities.Transform.MapToWorld(new System.Drawing.Point(e.X, e.Y), m_map);
img = m_map.GetMap();
string imgID = SharpMap.Web.Caching.InsertIntoCache(5, img);
imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);
}
Cheers
Jim
Detecting mouse clicks was easy. The following works for me to pan around a map:
ASP.NET code:
<asp:ImageButton Width="1000" Height="700" ID="imgMap" runat="server" OnClick="imgMap_Click" style="border: 1px solid #000;" />
C# code:
protected void imgMap_Click(object sender, ImageClickEventArgs e)
{
myMap.Center = SharpMap.Utilities.Transform.MapToWorld(new System.Drawing.Point(e.X, e.Y), m_map);
img = m_map.GetMap();
string imgID = SharpMap.Web.Caching.InsertIntoCache(5, img);
imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);
}
Cheers
Jim
Vedat
Mar 14 2007 at 6:54 AM
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!
- Detecting a click / displaying ToolTips
- Displaying a List
- tooltips
- tooltips
- tooltips
- Javascript detecting a mobile browser
- Adding and displaying a background
- Tutorial 2: Detecting a Valid PE File
- Detecting a mobile browser in ASP.NET
- Detecting a mobile browser in ASP.NET
- Displaying icons in a Flex List control
- 转:UIWebView displaying a network loading
- JavaFTP - Displaying a custom file structure
- Displaying XML in a Swing JTree
- 7.4 Displaying Pins on a Map View
- Scrolling a UITableView When Displaying the Keyboard
- Bitmap Topics: Displaying From a File
- Scrolling a UITableView When Displaying the Keyboard
- 一輩子受用的 Regular Expressions -- 兼談另類的電腦學習態度(转)
- 网页播放视频解决代码
- 关于VC启动时产生MSDEV-应用程序错误的处理
- ajax初学笔记
- 国家级示范高等职业院校网址
- Detecting a click / displaying ToolTips
- Label filtering
- 扩展GridView控件(一)——鼠标经过行时改变行的样式
- windows核心编程9
- Javascript中Window.open参数详解
- 微软亚洲技术中心面试题
- Road Layer
- (webabcd)我们来写一个继承自GridView的控件
- Anders Hejlsberg