hello,
I using InMemoryFeatureLayer query point on osm online map. And the map using wpfMap1.MapUnit = GeographyUnit.Meter;
the ‘point’ from :
Point screenPoint = Mouse.GetPosition(map);
PointShape point = wpfmap.ToWorldCoordinate(screenPoint);
the query function code :
/*
this.FeaturesLayer is a InMemoryFeatureLayer, and it’s point of collection;
the function can realize that click map and get FeaturesLayer’s Collection<Feature> features.
the function like ArcGIS function:
Collection<Graphic> graphics = await this.graphicsLayer.HitTestAsync(mapView, screenPoint, int.MaxValue);
*/
Collection<Feature> features= this.FeaturesLayer.QueryTools.GetFeaturesWithin(new EllipseShape(point, 100, 100), ReturningColumnsType.AllColumns);
However,it hava a bug,new EllipseShape(point, 100, 100) have a problem:
Local map zoom in, the circle will enlarge.I need like using screen point,because local map zoom in, the circle will not enlarge.It’s like a reasonable method.
Can you use screenPoint to query this.FeaturesLayer.Please give me some advice and tips.
Thanks for your help.
Regards.
Burning
How to use screenPoint query InMemoryFeatureLayer
Hi Burning,
The EllipseShape is based on world coordinates, which means the shape is a geometry shape. In your case, when we zoom in/out, we need to recalculate the shape with the below codes:
Point screenPoint = Mouse.GetPosition(map);
int toleranceInPixels = 5;
RectangleShape bufferredPoint = new RectangleShape(Map1.ToWorldCoordinate(screenPoint.X - toleranceInPixels, screenPoint.Y - toleranceInPixels), Map1.ToWorldCoordinate(screenPoint.X + toleranceInPixels, screenPoint.Y + toleranceInPixels));
this.FeatureLayer.Open();
Collection<
Feature
> features = this.FeatureLayer.QueryTools.GetFeaturesWithin(bufferredPoint, ReturningColumnsType.AllColumns);
Please let us know if any questions on the codes.
Thanks,
Troy