Hello Team,
I have a requirement of the map click/hover event. So, the use case is :
Platform using - Xamarin.forms for iOS, Android, UWP
Solved! Go to Solution.
I believe you are just showing the polygons of a shapefile being selected. This should work with the method I previously mentioned. When you identify the layer you can filter it by to only use the shapefile layer result and then select the feature. I think it would look like this, but I haven't done exactly what you are trying so this is just my best suggestion to try. the key is to identify the layer to select from and the feature to select.
var reidentifyResultssults = await mapView.IdentifyLayersAsync(e.Position, 15, false, 10);
foreach (IdentifyLayerResult layerResult in identifyResults)
{
if (layerResult.LayerContent is FeatureLayer layer)
{
if (layer.FeatureTable is ShapefileFeatureTable table)
{
layer.SelectFeature(((Feature)layerResult.GeoElements.FirstOrDefault());
}
I think you are looking for the geotapped event on the map view. There a ton of good examples on this api. once you know what the geo elements layer is you can determine if it is a Shapefile or KML and then select,show callouts, etc..
<esriUI:MapView x:Name="mapView" GeoViewTapped="mapView_GeoViewTapped" />
then handle it and search the area tapped.
private async void mapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Xamarin.Forms.GeoViewInputEventArgs e)
{
var results = await mapView.IdentifyLayersAsync(e.Position, 15, false, 10);
foreach (var result in results)
{
var attributes = result.GeoElements.FirstOrDefault().Attributes
Hey Craig,
Thanks for your reply. I looked into the GeoViewTapped event.
But my requirement is more of selecting the map areas from overlayed KMLLayer.
Please check attached video for reference. (In this video it is bing map and KMZ file is ovelayed over it, and user can select map areas from this KMZ file)
Can you please help me with how can I achieve this?
Thanks,
Kavita
I believe you are just showing the polygons of a shapefile being selected. This should work with the method I previously mentioned. When you identify the layer you can filter it by to only use the shapefile layer result and then select the feature. I think it would look like this, but I haven't done exactly what you are trying so this is just my best suggestion to try. the key is to identify the layer to select from and the feature to select.
var reidentifyResultssults = await mapView.IdentifyLayersAsync(e.Position, 15, false, 10);
foreach (IdentifyLayerResult layerResult in identifyResults)
{
if (layerResult.LayerContent is FeatureLayer layer)
{
if (layer.FeatureTable is ShapefileFeatureTable table)
{
layer.SelectFeature(((Feature)layerResult.GeoElements.FirstOrDefault());
}
Hey Craig,
In the attached video it is actually the polygons defined in the KMZ file, and in real-time it could be KML, KMZ, or shapefile. I will try out the snippet given by you for shapefile but do you have any idea that how will it work for the polygons defined in KMLLayer( for KML, KMZ files)?
Have not worked with KML in ESRI much. Add a break point and inspect the results of the IdentifyLayersAsync. I suspect you will get a KmlDocument Type ad/or KmlDataset. You should be able to select a feature that way. Hope that helps.
Hey Craig,
Thanks for your help.
I used the shapefile FeatureLayer and KmlDocument for KML/KMZ files and was able to implement select feature.