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.
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?
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.
Hope this helps.
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.