deck+Google GeoJsonLayer
by felixp
HTML
<!DOCTYPE html>
<html>
<head>
<title>deck.gl+Google</title>
<script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
<script src="https://unpkg.com/[email protected]/dist.min.js"></script>
<script
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&v=beta&map_ids=fae05836df2dc8bb"
></script>
<!-- jsFiddle will insert css and js -->
</head>
<body>
<div id="map"></div>
</body>
</html>
CSS
/* Always set the map height explicitly to define the size of the div element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
JavaScript
const AIR_PORTS =
'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_10m_airports.geojson';
function initMap() {
const map = new google.maps.Map(document.getElementById("map"), {
center: {lat: -34, lng: 150},
gestureHandling: 'greedy',
mapId: 'fae05836df2dc8bb',
zoom: 3
});
const airportsLayer = new deck.GeoJsonLayer({
id: 'airports',
data: AIR_PORTS,
filled: true,
pointRadiusMinPixels: 2,
pointRadiusScale: 2000,
getPointRadius: f => 11 - f.properties.scalerank,
getFillColor: [200, 0, 80, 180],
pickable: true,
autoHighlight: true,
onClick: info =>
info.object && alert(`${info.object.properties.name} (${info.object.properties.abbrev})`)
});
const overlay = new deck.GoogleMapsOverlay({
layers: [airportsLayer]
});
overlay.setMap(map);
}
initMap();