Add Feature With Different Projection

10 Dec

In my previous post, I showed how to query from one coordinate system and get the results in another. This was all in an effort to add a feature to an ESRI feature class in 2903 using leaflet.js in 4326. I remembered that some services allow you to specify an inSR, however, that option was missing in the addFeature capabilities.

I took a minute to read the documentation and viola! you can specify an input coordinate system. So now you can go from 4326 using leaflet.js to any coordinate system in ESRI using REST. All you need to do is pass a spatial reference in your geometry and ESRI will handle the conversion for you.

I have 4326 (lat,long) and want to send to 2903:

[{“geometry”:{“x”:-106,”y”:35,”spatialReference” : {“wkid” : 4326}}}]

This tells the service that I  know you are in WKID:2903 but I am giving you WKID:4326, deal with it. And it does!

I will admit that I am awful with projections and coordinate systems and this is a great way for me to avoid them…..for now.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: