So someone else explain this to me:
I have a Pro project (currently using 2.7.4) with a map in WGS84. To this I add a layer that is NAD27. NAD27 data is transformed on the fly to line up with WGS84 basemap. Great. That's what I've come to expect for many years.
Now, I publish this as a map service to ArcGIS Server and create an app using that service.
Next, I create a layout template using my Pro map and export to file.
Then I use Javascript and Python to create a web map from JSON passed from web app into GP service using my layout (creating in-memory APRX). What I end up with are service layers (from map service) and what I think ESRI has dubbed staged vector layers (from the layout template).
The map now basically has set of 2 of each layer.
But those staged vector layers, while lining up with basemap in Pro project, no longer line up. They now plot like good ole NAD27 in Web Mercator land.
I don't think that layer templates have any record of spatial reference. But is there a way to avoid this? Is this by design? Has this always been like this? I haven't noticed it before. When I export the "in-memory" APRX to file and open in Pro, I see that things don't line up and that no coordinate system transformation has been specified. Well, duh! When I do that in Pro, things snap right back to where I'd like to see them.
Is there a way to do do programmatically as part of my geoprocessing logic?
If you "Project" all your layers to your preferred coordinate system, that would remove the "on-the-fly" component from the equation. Would the web mercator thing still be an issue?
yeah, and if I just went with a different product rather than Pro ... maybe I would never have any of these headaches - haha!
Hi Arne,
I believe you correct when you state "I don't think that layer templates have any record of spatial reference." Map frames on a layout (and layout file/template) simply reference a map. It is the map that handles the spatial reference and applying any transformations/on-the-fly projection to any layers whose native spatial reference is not the same as the map's.
What might explain the "2 sets of layers" is if the layout file (template) was created with the map frame pointing to a map with layers, in which case that map and those layer will automatically be there every time you use the template. If you want the map frame to start out as empty you will need to create the template with an empty map frame. For more information please see Layout files—ArcGIS Pro | Documentation.
I highly doubt this issue is specific to layout file/template.
However, the title of this post certainly makes it look like this is question/issue with layout templates. Unfortunately I am not an expert in publishing workflow can cannot comment on the specifics of your workflow. Perhaps revising the title of this post to highlight the Javascript/Python/Publishing aspect of the question might get the attention of others with more expertise in these areas might help. Also, you might want to consider posting this question in the appropriate Javascript/Python/Publishing communities as well.
Hope this helps.
Tom
Agree with you that this likely goes beyond affecting my work with layout templates.
Like the suggestion to post more widely. Will do that and also am enlisting ESRI Support on this.
Thanks for taking the time to read my cry for help. Haha, Always appreciated.