I want to render a point on my map based on XY-coordinates and a spatial reference. This all works very well. But when setting this point as center at the creation of a new MapView, the map centers to lat 0, lon 0. Does anybody have an idea how to set this up correctly.
I'm using the following map: https://basisregistraties.arcgisonline.nl/arcgis/rest/services/BAG/BAGv3/MapServer
As said on the page, the spatial reference is 28992 and this is correct because the point is rendered on the correct position. I don;t have the latitude and longitude available, so I need to center the map with X and Y.
Here is a CodePen of my problem: Center based on XY coordinates (codepen.io)
Can anybody help me with this?
You can't use one of the default basemaps if you wan to use the center in another spatial reference. When using the default basemaps it needs to be in lat/long. You can reproject your point using the projection in the API. If you only want to work in your projected coordinates, you can make the MapImageLayer the base layer and the MapView will now be in the source SR. Here is a sample doing that.
Downside to this is you need to find or publish or your own basemap data if you need it.
Sadly, the projection returns no suitable transformations...
I will look for another map to render as the basemap. Can it be rendered below the base? Or should I just load the layer that is used as the basemap another time on top of the other layer?
Another option is to convert the point into WGS84 for the view, so you can still have the same basemap, like this: https://codepen.io/noash/pen/poWbxEm?editors=1000
I would like to add to your response Noah-Sager.
I had an issue where I want to zoom to the different features. This did not work, since the basemap is in another spatial reference, which is documented here and here.
In my application, I query all the features from an ArcGIS server and the only thing I did was specify the OutSpatialReference of all my queries to WebMercator with wkid: 102100 and latest wkid: 3857. Now all my features have the same spatial reference as the basemap, which makes things easier when wanting to use a feature's geometry to center the mapview or zoom to that feature.
Hope this may be of use to the OP.