Skip to content

Commit

Permalink
Added popup on click feature
Browse files Browse the repository at this point in the history
Removed direction api
  • Loading branch information
bsrinivasa committed Jul 20, 2016
1 parent 3c3829d commit 872cea5
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,27 @@
hash: true
})

map.on('click', function(e) {
var features = map.queryRenderedFeatures(e.point, { filter: ["has", "name"]});
if (features.length) {
var feature = features[0];
new mapboxgl.Popup({ closeOnClick: true })
.setLngLat(e.lngLat)
.setHTML('<p>' + feature.properties.name + '</p>')
.addTo(map);
}
});

var popup = new mapboxgl.Popup({closeOnClick: false})
.setLngLat([76.94,13.32])
.setHTML('<h1>Welcome to Gubbi!</h1><p>Close this message to continue.</p>')
.addTo(map);
.setLngLat([76.94, 13.32])
.setHTML('<h1>Welcome to Gubbi!</h1><p>Close this message to continue.</p>')
.addTo(map);

map.addControl(new mapboxgl.Geocoder());
map.addControl(new mapboxgl.Directions());
// map.addControl(new mapboxgl.Directions());
map.addControl(new mapboxgl.Geolocate({ position: 'bottom-right'}));
map.addControl(new mapboxgl.Navigation({ position: 'top-right' }));



</script>

</body>
Expand Down

0 comments on commit 872cea5

Please sign in to comment.