Esri Leaflet

Center the map

Geocode an address and then center the map on it automatically. This demo relies of the Esri Leaflet Geocoder plugin.

  <meta charset=utf-8 />
  <title>Center the map</title>
  <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

  <!-- Load Leaflet from CDN-->
  <link rel="stylesheet" href="" />
  <script src=""></script>

  <!-- Load Esri Leaflet from CDN -->
  <script src=""></script>

    body { margin:0; padding:0; }
    #map { position: absolute; top:0; bottom:0; right:0; left:0; }

<link rel="stylesheet" href="">
<script src=""></script>

<div id="map"></div>

  var geocoder = L.esri.Geocoding.geocodeService();

  var map ='map');

  L.tileLayer('https://{s}{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="//">OpenStreetMap</a> contributors'

  geocoder.geocode().text('New York City').run(function (error, response) {