Add WKT data on map

3137
3
08-29-2016 08:06 AM
ozcandurak
New Contributor III

Hi,

I m creating a search engine which returns WKT data. How can i use and display it on map with IOS ArcGIS SDK ?

I m not sure if i m on the right path but so far here is what i have achieved. Not able to find any sample either.

Here is a sample which i have created with WKT data :

var WKT_Data = "LINESTRING (514108.3456489 4252278.0780065, 514132.2315816 4252286.3389939, 514154.3147193 4252293.9783672, 514159.3727057 4252295.4812072, 514166.303487 4252297.5412621, 514193.4674137 4252305.6154771, 514198.4214004 4252307.0887163, 514225.8693286 4252314.3637349, 514227.5265242 4252314.8017481, 514253.7752555 4252321.7591571, 514257.9124447 4252322.8547901, 514311.1283029 4252337.9844123, 514321.9850699 4252342.7084961, 514325.2410523 4252347.2185167, 514333.7658062 4252359.0265708, 514356.7316894 4252387.8787207)"

    

var line = AGSSpatialReference.spatialReferenceWithWKID(5253, WKT: WKT_Data)

Regards.

Tags (3)
0 Kudos
3 Replies
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Ozcan,

Your code looks right if purely talking about the syntax format based on our documentation here:

10.2.5: AGSSpatialReference Class Reference 

As long as the data that you input with WKT data value is valid

ozcandurak
New Contributor III

So how will i able to draw the WKT on the map. ?

0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

There are two things you mixed up. 

1. You can not draw a spatialReference on the map. This line below you will get is a SpatialReference rather than a line

var line = AGSSpatialReference.spatialReferenceWithWKID(5253, WKT: WKT_Data)

2. If you want to show this "LINESTRING" polyline on the map. You need to parse this String into a valid format for Esri "Geometry Object". Basically you need to check this documentation from here:ArcGIS REST API - Geometry objects to find the right style of geometry. Then you need to use pure Swift to parse the "String" you get to convert to a valid geometry object.

Eventually, based on what type of geometry that you want to init the geometry on the map. For example, the geometry we converted as a "Polyline", then use this AGSPolyline Class to create the geometry, check this documentation: AGSPolyline - initWithJSON:spatialReference: 

Hope this help

0 Kudos