We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Load shapefile from local storage

Hello,

Is it possible to load shapefiles from local storage in Xamarin Forms sfMaps? I tried both a local path "/data/..." as well as a file Uri "file:///data/..." on Android, however both was not working and gave me a "Java IO Path not found" exception. Any thoughts?

Many thanks,

Christian

1 Reply

BK Bharathiraja K Syncfusion Team February 1, 2019 09:51 AM UTC

Hi Christian, 
 
Greetings from Syncfusion! 
 
We have the support to load the shape file as stream. Hence, you can achieve your requirement by converting the accessed shape file (from your device location) to stream and load to maps using ReadAsStream() method. 
 
Please refer the below code snippet for loading shape files as stream. 
  
// Load Shape file only 
ShapeLayer.ReadAsStream(stream);  
 
 
// Load Shape file and dbf file 
ShapeLayer.ReadAsStream(shstream, dbstream); 
  
 
We have prepared the sample to load the shape file from the application. Please find the sample from the following location. 
 
 
Note: We need to convert the loaded shape file into stream and then load stream into maps. 
 
Thanks, 
Bharathiraja. 


Loader.
Live Chat Icon For mobile
Up arrow icon