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

Json data is not displayed

            ShapeFileLayer layer = new ShapeFileLayer();
            layer.ShapeSettings = new ShapeSetting() { ShapeFill = Color.Coral, ShapeStroke = Color.Black, ShapeStrokeThickness = 1 };
            Assembly assembly = typeof(MapDeskPageViewModel).GetTypeInfo().Assembly;
            Stream shpStream = assembly.GetManifestResourceStream($"IT2media.XamarinForms.TestApp.MapsShapeFiles.world-map.shp");
            layer.ReadAsStream(shpStream);
            Layers.Add(layer);

=> Ok

            ShapeFileLayer layer = new ShapeFileLayer();
            layer.ShapeSettings = new ShapeSetting() { ShapeFill = Color.Coral, ShapeStroke = Color.Black, ShapeStrokeThickness = 1 };
            Assembly assembly = typeof(MapDeskPageViewModel).GetTypeInfo().Assembly;
            Stream jsonStream = assembly.GetManifestResourceStream($"IT2media.XamarinForms.TestApp.MapsShapeFiles.world-countries.json");
            layer.ReadAsJsonStream(jsonStream);
            Layers.Add(layer);

=> not displayed. no errors and jsonStream is not empty.

Attachment: worldcountries_750b5795.rar

5 Replies

BK Bharathiraja K Syncfusion Team February 28, 2019 12:53 PM UTC

Hi Dolgi, 
 
Greetings from Syncfusion. We are able to reproduce the issue. Currently, we are validating the issue and we will update the status on 4th March,2019. 
 
You can try the other option by converting the json file in to shape file and load the shape files using the ReadAsStream method. 
 
Please refer the following link to convert json files to shape files. 
 
Regards, 
Bharathi 



SC Scott August 22, 2019 05:58 PM UTC

Any update on this? I'm taking a string of GeoJson that I validated at GeoJsonLint.com and trying to add it to a SFMap with this:

string sGeoJson = BuildGeoJson(lPoints);
ShapeFileLayer shapeFileLayer = new ShapeFileLayer();
MemoryStream memoryStream = new MemoryStream();
StreamWriter streamWriter = new StreamWriter(memoryStream);
streamWriter.Write(sGeoJson);
streamWriter.Flush();
memoryStream.Position = 0;
shapeFileLayer.ReadAsJsonStream(memoryStream);
TheMap.Layers.Add(shapeFileLayer);

And I can see no effect. I'm building the GeoJson at runtime, so it's not like I can pre-convert GeoJson to a shapefile. 

A secondary question is if, the GeoJson can be loaded and displayed, is styling like either one of these supported?

      "style": {
        "stroke": "#ff0000",
        "stroke-width": "3",
        "stroke-opacity": 1,
        "marker-size": "medium",
        "marker-symbol": 0,
        "marker-color": "#ff0000"
      },
      "properties": {
        "prop0": "value0",
        "prop1": 0,
        "stroke": "#ff0000",
        "stroke-width": "3",
        "stroke-opacity": 1,
        "marker-size": "medium",
        "marker-symbol": 0,
        "marker-color": "#ff0000"
      }




RA Rachel A Syncfusion Team August 23, 2019 12:11 PM UTC

Hi Scott, 
 
Query 1: Binding json data at run time 
 
As of now we are having this support only for Android platform. Also, we have considered this support as feature enhancement internally for other platforms (iOS, UWP) and will be available in any of the upcoming release. 
 
Query 2: Setting style for maps in json file 
 
You can set the customization properties directly in Maps as there is no support for setting the properties in json file. To know more on markers customization, refer the documentation link below. 
 
 
Thanks, 
Rachel. 



SC Scott August 23, 2019 01:13 PM UTC

Regarding Query 1: Only Android won't help us very much. And I'm mainly developing / testing on Android right now. And even Android it isn't working for me. 

I guess the question is, when is the upcoming release that will work in Android and also in iOS / UWP? I realize release dates are glorious opportunity to make yourself into a liar, but if you could give me a general ballpark that would be helpful to us to assess what / where we go now.

Re: Query 2:

I was trying to set ShapeSetting for the layer:

            ShapeSetting shapeSetting = new ShapeSetting();
            shapeSetting.ShapeStroke = Color.Red;
            shapeSetting.ShapeStrokeThickness = 2;
            shapeFileLayer.ShapeSettings = shapeSetting;

But that wasn't working either (per Query 1). It would be more flexible to include the styles in the GeoJson so you could have red points and green lines or whatnot. But I understand you're not supporting that. 



RA Rachel A Syncfusion Team August 26, 2019 12:11 PM UTC

Hi Scott, 
 
Query 1: Regarding timeline for json runtime support in iOS and UWP 
 
We have considered this feature for Volume 4 main release which is scheduled to be released on mid of December 2019. 
 
Also, we have checked by binding the json data, it is working fine in Android. Please find the sample attached below. 
 
Query 2: Regarding styles set in shape settings 
 
We have prepared sample to display the shape settings and you can download from the following location. 
 
 
Output: 
 
 
Please let us know if you face any problems. 
 
Thanks, 
Rachel 


Loader.
Live Chat Icon For mobile
Up arrow icon