Bias geocoder results around the map view

Use the mapbox-gl-geocoder control to search for places using Mapbox Geocoding API biasing results nearby the map's current view.

<!DOCTYPE html>
    <meta charset='utf-8' />
    <title>Bias geocoder results around the map view</title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
    <script src=''></script>
    <link href='' rel='stylesheet' />
        body { margin:0; padding:0; }
        #map { position:absolute; top:0; bottom:0; width:100%; }

<script src=''></script>
<link rel='stylesheet' href='' type='text/css' />
<div id='map'></div>

mapboxgl.accessToken = '<your access token here>';
var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v9',
    center: [-79.4512, 43.6568],
    zoom: 13

var geocoder = new MapboxGeocoder({
    accessToken: mapboxgl.accessToken

map.on('load', updateGeocoderProximity); // set proximity on map load
map.on('moveend', updateGeocoderProximity); // and then update proximity each time the map moves

function updateGeocoderProximity() {
    // proximity is designed for local scale, if the user is looking at the whole world,
    // it doesn't make sense to factor in the arbitrary centre of the map
    if (map.getZoom() > 9) {
        var center = map.getCenter().wrap(); // ensures the longitude falls within -180 to 180 as the Geocoding API doesn't accept values outside this range
        geocoder.setProximity({ longitude: center.lng, latitude: });
    } else {

Copy example