Skip to main content

From JSON to MapPoint

Comments

4 comments

  • Permanently deleted user

    Roger,

    I've never tried assigning a mappoint to a parsed value so I looked over some of the workflows that I have that get the mappoint from user input and thought perhaps the following will work:

    create a variable:

     

    esriPoint esri.arcgis.client.geometry.MapPoint

     

    jsonX  double

     

    jsonY  double

     

    jsonSpatialExtent Int32

    parse out spatialreference, x, and y from the json string

    assign

    esriPoint.X = jsonX

     

    esriPoint.Y = jsonY

     

    esriPoint.spatialreference   = new esri.ArcGIS.Client.Geometry.SpatialReference(jsonSpatialExtent)

     

     

    0
  • Permanently deleted user

    Hi Roger,

        Out of curiosity, where did you get the Json from? Is it just hard coded, or did you get it from some interaction with the client? If you properly type variables as Geomety in the workflow, they would be created correctly coming from the client.

        We have some internal methods that we use in the product to get geometry from Json. I'll put in a feature request to expose it as public in the future (won't help you right now). 

    Cheers,

    Christian.

    0
  • Permanently deleted user

    I knew someone would ask.  I have my own geocoding service that's specific to the city I work for.  It used to be SOAP based, but I added a REST endpoint last week.  But now that I can get a JSON response from geocoding in the URL, I don't know what to do with it.  I've tried casting the string to a MapPoint or a Geometry and many other things.  I thought it would be simple, but I guess it's not.

    As far as the parsing goes, I was hoping I could find a class that would do it for me (you know, stripping out the quotes, breaking on commas, etc.)  I did see a class called JsonReaderWriterFactory, but don't know how to use it.  I just need something to break that JSON value into pairs, and then read the X and Y.  Then I'd feel comfortable giving those to a new MapPoint.

    0
  • Permanently deleted user
    Try this:

     

    Geometry geo = new MapPoint  //Assign

     

    MapPoint pt = geo.FromJson(strJson) //Cast to point
    0

Please sign in to leave a comment.