Hi,
how can I use an ImageryLayer and a ShapeFileLayer on a sfMap?
I need the following:
- ImageryLayer for the map (bing or google)
- ShapeFileLayer with several polygons. The polygons don't come from a shp-File but will be added by code (each polygon is defined by a list of points).
- The polygons must be selectable or at least tappable, so that the app can recognize, when a user taps on a polygon.
I can't provide any code. I tried every example I could find, but nothing seems to work (completely).
What worked:
Showing a map with ImageryLayer. Adding polygon by adding a ShapeFileLayer for each polygon to the SubLayers-Property of the ImageryLayer. In this case the polygons are visible, but it's not possible to select or tap a polygon.
Any help would be appreciated.
Thanks.
Regards.
Alex
[Edit: fixed lost formatting]
Query 1: ImageryLayer for the map (bing or google)
To use Bing maps, set the LayerType property of ImageryLayer to “Bing” and set the Bing Maps key. We can also load the custom map providers map such as Google Maps using the RequestTileUri event of ImageryLayer. Please find the below documentation for more information.
https://help.syncfusion.com/xamarin/maps/mapsprovider#load-custom-map
https://help.syncfusion.com/xamarin/maps/mapsprovider#bing-maps
Query 2: ShapeFileLayer with several polygons. The polygons don't come from a shp-File but will be added by code (each polygon is defined by a list of points).
We can add the polygon from shape file as sublayer. We have prepared a simple sample to show that polygon is added as sublayer from shape file. In the sample we have added a polygon shape file named Australia. Please get the sample from the below attachment. We suspect that the provide shape file may be in wrong format so that it is not loaded correctly. So can you please share the shape file which you have used in your project, so that it will help us to check and provide an appropriate solution at the earliest.
Query 3: The polygons must be selectable or at least tappable, so that the app can recognize, when a user taps on a polygon.
SfMaps does not have selection support for sub layers. So, we can’t select or tap the polygon which are added in sublayers. So, we have logged a feature request this and it can be tracked through our feedback portal below.
https://www.syncfusion.com/feedback/32469
Please cast your vote to make it count. We will prioritize the features every release based on the demands, since we don't have an immediate plan to implement this feature and it will be included in any of our upcoming releases.
If you have any more specifications/suggestions
to the feature-request, you can add it as a comment in the portal
Thanks for your reply, although it's not, what I hoped for.
I'm must add polygons by code and almost every sample including yours use shape-files.
I managed to add polygons to the imagerylayer, but these are not selectable nor tappable. So I upvoted your feature request. Thanks for that.
At the moment I have to find a solution on my own, I'm afraid.
Thanks.
Regards.
Alex
As mentioned earlier,
SfMaps has support to load the polygon through the shapefile and we have shared
the sample for the same in our previous update. Still you have faced any
problem in loading the polygon in SfMap. Please revert us with issue replication
sample based on your application scenario. It will help us to provide an
appropriate solution at the earliest.
OK, maybe I wasn't clear or maybe there is a misunderstanding between us or about the capabilities of sfMaps in general.
Anyway, let me try again:
I want to do the following:
A) Show a map in satellite view (bing or google).
B) Draw some ploygons, polylines and markers on this map. I must do this by code, I can't use a shape file.
C) React, when a user taps on a polygon (the main purpose is, that a user can select one or more polygons, so that they can be highlighted in some way).
What I've done so far:
A
This is easy by using an ImageryLayer either with LayerType=Bing or use mMapBaseLayer_RequestTileUri
B
For each polygon I added a ShapefileLayer to the SubLayers-Property of the ImageryLayer and set the Points-Property to draw the Polygon. This works, but it feels wrong to me in some kind. For e.g. 30 polyons I have to add 30 ShapefileLayers to the SubLayers. Is there a better way? Is it possible, to add multiple polygons to the same Layer?
For Markers I use the MarkerItemSource with a templateselector. This seems to work so far.
C
Haven't solved this yet. I wanted to use the SelectedItems-Property but this doesn't work with SubLayers as you mentioned. For the same reason the ShapeSelectionChanged event doesn't work.
So I'm going to solve this by responding to the tapped event on the map and determine the polygon at this location. This doesn't sound too difficult, but maybe you can tell me, if there is a better way?
Besides this, I'm missing these two things:
1. Showing a pin or marker for the current location of the user.
2. Showing some controls on the map for zooming in/out.
I can implement these features on my own, but it would be nice to have this built in.
Thanks.
Regards.
Alex
Query A:
We are glad to hear that you have achieved your requirement.
Query B:
Currently, our development team is checking the reported query, and we will update further details on July 27, 2022.
Query C:
As mentioned earlier, SfMaps does not have selection support for sub layers, and we don’t have any workaround to achieve this requirement. We have already logged a feature request this and it can be tracked through our feedback portal below.
https://www.syncfusion.com/feedback/32469
Please cast your vote to make it count. We will prioritize the features every release based on the demands, since we don't have an immediate plan to implement this feature and it will be included in any of our upcoming releases.
If you have any more specifications/suggestions to the feature-request, you can add it as a comment in the portal
Query D: Showing a pin or marker for the current location of the user.
We would like to inform you that, already we have already published a knowledge base to achieve your requirement. Please find the knowledge base link below
https://www.syncfusion.com/kb/11379
Query E: Showing some controls on the map for zooming in/out.
Currently SfMaps control doesn’t have the support to achieve your requirement. We have already logged a feature request for this requirement and it can be tracked through our feedback portal below.
https://www.syncfusion.com/feedback/8755
Please cast your vote to make it count. We will prioritize the features every release based on the demands, since we don't have an immediate plan to implement this feature and it will be included in any of our upcoming releases.
If you have any more specifications/suggestions to the feature-request, you can add it as a comment in the portal.
Query B:
We can load large
number of polygons in single ShapeFileLayer by using ShapeFile or JSON file (as
we load world map, Australia, etc.). But in your scenario, there is only one way
than creating a separate ShapeFileLayer for each polygon.