How to display json data on the map
In geocortex workflow, how can I display the json data on the map?
I have a webRequest activity to get geojson data from API. The GET request returns json data with valid geometry. Now how can I display this json data on the map? which workflow activity can I use?
0
-
You will need to create new geometries (or Graphics), and then use the AddMarkup or AddMarkupFeature command to add those to the map. This can be done, but it won't give you a nice readable workflow...
If you are a developer, or know one, I would recommend to create a reusable custom workflow activity that does the conversion for you.
It should also be possible to use an external library such as GDAL or GeoJson-Net to do the parsing. I haven't tried this myself.
Here's how to do it in a workflow:- Start by using Json To Dictionary. This will return a IDictionary(Of String, Object), containing the keys type and features.
- The type of the features entry will be Array of Object, so you need Cast<T> to convert iDictionary1("features") to that.
- Use For Each to loop over this array
- Inside the loop, cast the current item to IDictionary(Of String, Object). This dictionary will contain type, geometry and properties.
- To get the coordinates, cast the geometry entry to IDictionary(Of String, Object)
- Depending on the type of geometry, use an Assign to create either New Geometry.MapPoint(), New Geometry.Polyline() or New Geometry.Polygon()
- If it's a Point geometry, cast coordinates to Array Of Double, if it's a LineString or Polygon, cast to Array of Array of Double
- Populate the geometry object you created earlier, for a Point you can set X and Y directly, for a Polyline you need its Paths property, for a Polygon its Rings property
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
1 kommentar