converting between projections for zooming to layer extents

1031
2
05-24-2017 11:07 AM
DataSteward
New Contributor III

As it exists, I'm using a batch of ImageServer and MapServer data in California state plane, while my view is using web mercator. I'd like to use some 'zoom to extent' actions.  Simply updating the view extent with the layer extents sends me off to odd parts of the world.  So apparently any reproject on the fly works for the services, but not when transferring extents - the spatialReference property seems to have no effect.  Tried both:

view.extent = featureLayer.fullExtent;

view.goTo(featureLayer.fullExtent);

So, I'm looking into projecting the xmin... values from my state plane layers into web mercator and using them to set the view extent.  I've constructed a point with state plane for the spatialReference, and checked it with

webMercatorUtils.canProject(myPoint, map);

but that returns false.  So I'm presuming that the arcgis api just can't project from state plane to web mercator?  Is there a list of projections that are functional?

Alternatively, do I just need to give up on going in this direction and get all my ImageServer and MapServer data projected to web mercator to start with?

Thanks!

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

You will have to use the GeometeryService Project method:

GeometryService | API Reference | ArcGIS API for JavaScript 4.3 

and specify ProjectParameters:

ProjectParameters | API Reference | ArcGIS API for JavaScript 4.3 

webMercatorUtils can only project between geographic and webmercator

DataSteward
New Contributor III

OK, thanks! I'll just get everything changed over to WebMerc.

 

0 Kudos