Display SQL Geography in ESRI JS

657
3
11-28-2016 08:35 PM
AlexeiB
Occasional Contributor

Hello,

How do I display SQL Geography in ESRI JS?

My API returns a geography I inserted into SQL from a tutorial I found.

"Shape": { "Geography": { "CoordinateSystemId": 4326, "WellKnownText": "POLYGON ((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))", "WellKnownBinary": null } }
I can write a parser for this and get it to show but it seems like it's a lot of work. I was wondering if anyone has done this before and has any tips?
Thanks,
0 Kudos
3 Replies
FC_Basson
MVP Regular Contributor

According to the API documentation (Polygon | API Reference | ArcGIS API for JavaScript 3.18 | Polygon | API Reference | ArcGIS API for JavaScript 4.1  ) there does not seem to be a way of constructing a polygon directly from the SQL WKT.  Parse and plot - should be easy enough.

0 Kudos
BenFousek
Occasional Contributor III

Check out GitHub - Esri/Terraformer: A geographic toolkit for dealing with geometry, geography, formats, and b... You'll need the WKT Parser module as well. A single AMD module with just the methods you need can be built with Browserify 

AlexeiB
Occasional Contributor

Thanks everyone. I ended up writing a simple parser for the geometry and it looks like it's working.

0 Kudos