Hi everyone,
I just needed some tips to be able to display a hover popup on a shape in a SQL2008 Layer.
I would like it to be as your sample on "websamples.thinkgeo.com" in "Marker" in "Set the hover popup for a marker"
Thank you.
Hi everyone,
I just needed some tips to be able to display a hover popup on a shape in a SQL2008 Layer.
I would like it to be as your sample on "websamples.thinkgeo.com" in "Marker" in "Set the hover popup for a marker"
Thank you.
I can't make it work.
In fact I get polygon shapes from the DB with a MsSql2008FeatureLayer.
I would like to display hover popups on these shapes and not on markers.
Please see attached sample screenshot from my app.
Thank you
Gautier,
Sorry we don't support hover on shapes now, could you please use click instead of hover as a workaround? Attached is the code.
Regards,
Edgar
002_001_post10880.txt (2.4 KB)
Can I send you my basic sample test project because I can’t make your code work, maybe I’m doing something wrong ?
I’m sorry Gautier, it looks like the attached file has something wrong, please get the updated one and have a try. If you want to send your sample to us, you can send it to forumsupport@thinkgeo.com.
Regards,
Edgar
I would really need hover because I already have a click action which displays a popup with much more details.
The idea is that the hover popup (or div) shows only 2 or 3 basic informations.
Can’t this even be done on the client side in JS ?
Thank you.
Hello Gautier,
Sorry, as far as I know, it’s not suitable for client side handle it, because openlayer do not have the feature, so you have to call the server to know if your mouse is within or out the feature shape, to do this, every mouse move event, we need call server and wait the response back, that will great delay your user experience.
Sorry for the inconvenience,
Regards,
Gary
Could you please give a sample code for that, I would like to give it a try ?
Thank you.
Hello Gautier,
First, let your class inherit the ICallbackEventHandler, then implement the RaiseCallbackEvent and GetCallbackResult function.
public string GetCallbackResult()
{
return "necessary value";
}
public void RaiseCallbackEvent(string eventArgument)
{
double x = Double.Parse(eventArgument.Split(':')[0]);
double y = Double.Parse(eventArgument.Split(':')[1]);
PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, new ScreenPointF((float)x, (float)y), (float)Map1.Width.Value, (float)Map1.Height.Value);
//get your feature and jugement if the mouseLocation with in the feature, if true, show your popup, else do nothing. Or if you want to add the popup in the client side, returen
//necessary value back to client side.
}
Then in the client side, register mousemove event in your page:
(body onmousemove="move()")
Every move will call server and pass the mouse location to server side, it will raise the RaiseCallbackEvent and return value to js function by GetCallbackResult.
function move() {
var mouseX = event.clientX;
var mouseY = event.clientY;
callServer(mouseX+":"+mouseY);
}
function callServer(param){
<%= ClientScript.GetCallbackEventReference(this, "param", "receiveServerData", null)%>;
}
function receiveServerData(columnValue){
// show popup if you want to do it in client side.
}
I hope this can help, but it really will be very slow because each pixel move will raise the event once.
Regards,
Gary
Thank you very much I’m going to give it a try.
I understand the problem of the multiple calls to the server but I plan to wait that the mouse remains at the same position for 500ms (for example) and only then call the server action… I need to do some testing on this but I think it’s gonna be ok
Calling a popup function on the client side when the answer comes back from the server is a good idea to speed up things I think so thank you for the idea I’m going to try that !
Will give you my feed back soon :)
Hello Gautier,
You are welcome, I hope everything goes smooth.
Regards,
Gary
Hi Gary, I did my sample projetc and I sent it to you on forumsupport@thinkgeo.com
My script for detecting that the mouse stopped moving for 1 second and call the server side only then works fine.
But I have 2 questions left:
- Why does my RaiseCallbackEvent function can’t find the features containing the mouselocation ?
- Why does my features in the MsSql2008FeatureLayer don’t display on the map ? (you can see them only because they are also added to the HighlightOverlay
Thank you very much for your help and I wish you a happy new year !
;-)
Any news on this problem ?
Thank you.
Hello Gautier,
Sorry for waiting, I just back from vacation.
I got your sample and database, but I met a problem that your database version is 661 but mine is 655 that I can't open your database.
I can't run depend on your sample, but I have checked the code, so for your first question, I did test on my side, code below:
Feature feature = new Feature(new MultipolygonShape("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((20 0,20 10,30 10,30 0, 20 0)))"));
Feature feature1 = new Feature(new PointShape(5, 5));
InMemoryFeatureLayer f = new InMemoryFeatureLayer();
f.InternalFeatures.Add(feature);
f.Open();
Collection<Feature> hoveredFeatures = f.QueryTools.GetFeaturesContaining(feature1, ReturningColumnsType.AllColumns);
I can get the result, so could you please check your mouse location and see if the coordinate get the right value?
For your second problem, I have noticed you are using OverlaySwitcher, so the MsSqlLayer never show up even you switch with the switcher? Can you try to remove your google overlay and set the MsSql overlay as baseOverlay and have another try?
Sorry for the inconvenience,
Regards,
Gary
Hi Gary,
I think the easiest way would be that you can run my sample project but I don't know how to convert my database to your version.
However it's such a basic table that you can reproduce it very easily:
And here are the features:
Test 1
0x0000000001040A000000F7B53000D7161040689154D927814840B11F527CAB161040464C68C00981484050D2469B07181040D733377E05814840B5AB8FCF5418104005F5617B28814840DDD288BF881810400C4139453F8148404274CEE0B9181040B8DDB7C1538148404868A1D630171040409D4CA256814840F751B209E51610405A2947372781484017C1979DDC1610403A91AB8F27814840F7B53000D7161040689154D92781484001000000020000000001000000FFFFFFFF0000000003
Test 2
0x00000000010407000000140E541B9C15104062ECD1A97C8048407A72D2118E1510406630D47B67804840CCFE93AD3918104091F79E7266804840E941FE5D5B181040F163AE657B804840616D92426D16104062ECD1A97C8048408D4B3CD81B16104062ECD1A97C804840140E541B9C15104062ECD1A97C80484001000000020000000001000000FFFFFFFF0000000003
I don't know if you can try with these informations ?
Thank you for your help.
Hi Gautier,
I think the reason that you didn't get anything on mouse move is that there is something wrong with the code we provided in our previous post, now you can update the two methods,
double x = Double.Parse(eventArgument.Split(':')[0]);
double y = Double.Parse(eventArgument.Split(':')[1]);
double w = Double.Parse(eventArgument.Split(':')[2]);
double h = Double.Parse(eventArgument.Split(':')[3]);
PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, new ScreenPointF((float)x, (float)y), (float)w, (float)h);
//Query the layer with this location
function move() {
var mouseX = event.clientX;
var mouseY = event.clientY;
var map = Map1.GetOpenLayersMap();
callServer(mouseX+":"+mouseY+":"+map.size.w+":"+map.size.h);
}
I think it will work this time. The feature information is helpless as we tried to convert it to wkb but failed, if the new methods cannot resolve your problem, could you please provide the wkb of the two features? A base64 string would be Ok.
Thanks,
Edgar
MapSuite still can’t find the feature I am hovering.
I updated my sample project accordingly and send it to forumsupport@thinkgeo.com.
Please could you tell me how I can extract the shape info in the format you need ?
Thank you.
Any news on this question ?
Thank you.
Hi Gautier,
I guess you can try HighlightOverlay if you don't have a big data for each extent. The attached is a demo based on your requirements, please have a try.
Thanks,
Johnny
Show_Info_on_polyon.zip (2.47 KB)