Hi Gautier,
How is everything goiing on?
Thanks,
Johnny
Dynamic info on a shape
Well I did not tried your new suggestion for the moment because I think we had almost solved the problem with all the work we did and now the solution changes completely from what we begun…
Moreover I already use highlight overlay for other purpose so the firest solution was better for me because I don’t want to be forced to use highlight overlay for those popups thing…
So if we please could finish the first solution it would be great for me.
I sent you a new sample project and asked how I could send you the feature in a format you can use.
Thank you.
You can use Select featureShape.STAsText() from table. to get the wkt.
Regards,
Edgar
OK so here is my table so that you can run my sample project:
featureID: 88b6e073-9e55-47a9-ab68-f17c2b3c90a1
featureShape: POLYGON ((4.0223045377474511 49.009028593342748, 4.0221385407566439 49.008110094954233, 4.0234665166832 49.007980133966775, 4.0237610274734168 49.009047911482448, 4.0239591529141 49.009743359523867, 4.02414656887146 49.010368551996578, 4.02264724121239 49.010456359299951, 4.0223580851638792 49.00900927519497, 4.0223259567140053 49.009019812367526, 4.0223045377474511 49.009028593342748))
featureName: Test 1
featureID: 0aa97c6a-816e-416b-b803-6060b36b2121
featureShape: POLYGON ((4.0211033124974342 49.003804423810621, 4.0210497650810968 49.003158072097719, 4.0236575242594874 49.003126456852563, 4.023786038058895 49.003765783454476, 4.02190116900178 49.003804423810621, 4.0215905939866277 49.003804423810621, 4.0211033124974342 49.003804423810621))
featureName: Test 2
Thank you.
Gautier,
Here is our code to achieve your goal,
client,
function move()
{
var mouseX = event.clientX;
var mouseY = event.clientY;
var map = Map1.GetOpenLayersMap();
var extent = map.getExtent();
callServer(mouseX+":"+mouseY+":"+map.size.w+":"+map.size.h+":"+extent);
}
function callServer(param)
{
<%= ClientScript.GetCallbackEventReference(this, "param", "receiveServerData", null)%>;
}
function receiveServerData(columnValue){ // show popup if you want to do it in client side.
if (columnValue === "True")
{
var map = Map1.GetOpenLayersMap()
for (var i = 0; i < map.layers.length; i++) {
map.layers[i].redraw(true);
}
}
}
server
public partial class DisplayASimpleMap : System.Web.UI.Page, ICallbackEventHandler
{
bool foundFeatures = false;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.MapUnit = GeographyUnit.DecimalDegree;
InMemoryFeatureLayer layer = new InMemoryFeatureLayer();
layer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
layer.InternalFeatures.Add(new Feature("POLYGON ((4.0223045377474511 49.009028593342748, 4.0221385407566439 49.008110094954233, 4.0234665166832 49.007980133966775, 4.0237610274734168 49.009047911482448, 4.0239591529141 49.009743359523867, 4.02414656887146 49.010368551996578, 4.02264724121239 49.010456359299951, 4.0223580851638792 49.00900927519497, 4.0223259567140053 49.009019812367526, 4.0223045377474511 49.009028593342748)) "));
layer.InternalFeatures.Add(new Feature("POLYGON ((4.0211033124974342 49.003804423810621, 4.0210497650810968 49.003158072097719, 4.0236575242594874 49.003126456852563, 4.023786038058895 49.003765783454476, 4.02190116900178 49.003804423810621, 4.0215905939866277 49.003804423810621, 4.0211033124974342 49.003804423810621)) "));
layer.Open();
Map1.CurrentExtent = layer.GetBoundingBox();
Map1.StaticOverlay.Layers.Add("layer", layer);
InMemoryFeatureLayer highLightLayer = new InMemoryFeatureLayer();
highLightLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Green);
highLightLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
highLightLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1;
Map1.DynamicOverlay.Layers.Add("highlight", highLightLayer);
Map1.StaticOverlay.IsBaseOverlay = true;
}
}
public string GetCallbackResult()
{
return foundFeatures.ToString();
}
public void RaiseCallbackEvent(string eventArgument)
{
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]);
string extent = eventArgument.Split(':')[4];
RectangleShape rect = new RectangleShape(Double.Parse(extent.Split(',')[0]), Double.Parse(extent.Split(',')[3]), Double.Parse(extent.Split(',')[2]), Double.Parse(extent.Split(',')[1]));
PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(rect, new ScreenPointF((float)x, (float)y), (float)w, (float)h);
InMemoryFeatureLayer layer = Map1.StaticOverlay.Layers["layer"] as InMemoryFeatureLayer;
layer.Open();
InMemoryFeatureLayer highlightLayer = Map1.DynamicOverlay.Layers["highlight"] as InMemoryFeatureLayer;
Collection<Feature> features = layer.QueryTools.GetFeaturesContaining(mouseLocation, ReturningColumnsType.AllColumns);
highlightLayer.InternalFeatures.Clear();
if (features.Count > 0)
{
foreach (var item in features)
{
highlightLayer.InternalFeatures.Add(item);
foundFeatures = true;
}
}
}
}
Regards,
Edgar