Skip to content

Instantly share code, notes, and snippets.

@SinZ163
Created June 3, 2018 15:46
Show Gist options
  • Select an option

  • Save SinZ163/e62fc6b8998bf4c22ec36ff4292cdf89 to your computer and use it in GitHub Desktop.

Select an option

Save SinZ163/e62fc6b8998bf4c22ec36ff4292cdf89 to your computer and use it in GitHub Desktop.
DeckGL bug
var deckgl = new deck.DeckGL({
container: 'map',
mapboxApiAccessToken: '**REDACTED**',
mapStyle: '**REDACTED**',
longitude: 144.5339197,
latitude: -37.8545151,
zoom: 9,
bearing: 30,
pitch: 30
});
var markerHeight = 50, markerRadius = 10, linearOffset = 25;
var popup = new mapboxgl.Popup({
offset: {
'top': [0, 0],
'top-left': [0,0],
'top-right': [0,0],
'bottom': [0, -markerHeight],
'bottom-left': [linearOffset, (markerHeight - markerRadius + linearOffset) * -1],
'bottom-right': [-linearOffset, (markerHeight - markerRadius + linearOffset) * -1],
'left': [markerRadius, (markerHeight - markerRadius) * -1],
'right': [-markerRadius, (markerHeight - markerRadius) * -1]
},
closeButton: false,
closeOnClick: false
});
deckgl.setProps({
layers: [
new deck.IconLayer({
data: [
{
position: [144.962593535096, -37.8099387667386],
name: "Melbourne Central Railway Station (Melbourne City)",
icon: "marker-2",
size: 24,
color: [0x00, 0x72, 0xCE]
}
],
id: "station-layer-2",
iconAtlas: 'https://i.imgur.com/SgeU7eN.png',
iconMapping: {
"marker-2": {
x: 32,
y: 0,
width: 32,
height: 32
}
},
pickable: true,
onHover: (info) => {
popup.remove();
if (info["picked"]) {
this.popup
.setLngLat(info.lngLat)
.setText(info["object"]["name"])
.addTo(deckgl.getMapboxMap());
}
}
})
]
})
<html>
<head>
<!-- Deck GL -->
<script src="https://unpkg.com/deck.gl@5.2/deckgl.min.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.css' rel='stylesheet' />
<!-- End Deck GL-->
<style>
#map {
position:absolute;
top:0;
bottom:0;
left: 0;
width:100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script src="code.js"> </script>
</body>
</html>
<html>
<head>
<!-- Deck GL -->
<script src="https://unpkg.com/deck.gl@5.3/deckgl.min.js"></script>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.css' rel='stylesheet' />
<!-- End Deck GL-->
<style>
#map {
position:absolute;
top:0;
bottom:0;
left: 0;
width:100%;
}
</style>
</head>
<body>
<div id="map">
</div>
<script src="code.js"> </script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment