JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.27.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.27.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:95%; transition: all 0.3s; }
</style>
</head>
<body onload="boundsload()" onresize="boundsload()">
<div id='map' style="z-index: -100; width:100%; height: 500px; border:1px solid red;"></div>
<div id='resizeDiv' class='button' style="display: none;">Resize container</div>
<div id='resizeMap' class='button'style="display: none;">Fix map</div>
<div style="z-index: 50000; background-color: white; border:1px solid red; width:100%; height:130px;">
MAP CENTER: <input type="text" id="mapcenter" name="mapcenter" value="target" style="width:85%; height:40px; font-size: 120%;"><br/>
MAP BOUNDS: <input type="text" id="mapbounds" name="mapbounds" value="target" style="width:85%; height:40px; font-size: 120%;"><br/>
Width:<input type="text" name="mapwidth" value="100%" onchange="resize();" type="number">(ex: 200px or 80%)<br/>
Height:<input type="text" name="mapheight" value="500px" onchange="resize();" type="number">(ex: 200px or 80%)
</div>
<script>
mapboxgl.accessToken = 'pk.eyJ1Ijoid2Vid3JpZ2h0IiwiYSI6ImNqOG9sbDFrOTA0dXMycW8zZXJmbmY0N3oifQ.mNAEsGXWeD28diaXAMfrhQ';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/webwright/cjhruf77z8iph2sn653da1q37',
center: [-122.28, 47.59],
zoom: 12
});
map.on('moveend', boundsload); // and then update proximity each time the map moves
function boundsload(){
var mapcenter = map.getCenter();
document.getElementById("mapcenter").value = mapcenter;
var mapbounds = map.getBounds();
document.getElementById("mapbounds").value = mapbounds;
}
function resize (){
var inputwidth = document.getElementsByName("mapwidth")[0].value;
var...