Center mapView base on address

897
2
Jump to solution
05-14-2020 04:03 AM
MagdalenaChmura
New Contributor

Hi, 

I center my map base on initial coordinates and it works perfect:

 

        const view = new MapView({
            center: [initialPointToCenterMap.xinitialPointToCenterMap.y],
            container: 'viewDiv',
            map,
            zoom: 14,
        });

I was wondering if there is an option to center map base on certain address like "London, 10 Downing Street"?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

No there is no option to center the map on an address. You easiest option is to Google the lat and lon for that address ahead of time and enter it. Another option would be to set the map center in code after the app initializes by using a Locator class and the adressToLocations method.

https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressesToLoc... 

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

No there is no option to center the map on an address. You easiest option is to Google the lat and lon for that address ahead of time and enter it. Another option would be to set the map center in code after the app initializes by using a Locator class and the adressToLocations method.

https://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#addressesToLoc... 

Egge-Jan_Pollé
MVP Regular Contributor

Hi Magdalena Chmura,

Another option of course would be to add a Search widget to the map, allowing users to enter an address to center the map themselves.

Inspired by your sample address (London, 10 Downing Street) I have created a little sample app using UK maps from Ordnance Survey.

The projection of this map is British National Grid (EPSG:27700). Address Search has been limited by applying countryCode:"GBR".

You can see the app (and the source) here:

ArcGIS JavaScript with UK data - Search address in the United Kingdom 

Best regards,

Egge-Jan

0 Kudos