diff --git a/js/map_maplibre.js b/js/map_maplibre.js
index 6733a59..2d45900 100644
--- a/js/map_maplibre.js
+++ b/js/map_maplibre.js
@@ -18,22 +18,35 @@ function maplibreMap() {
pitch: 0,
zoom: 1,
maxZoom: 20,
+ continuousWorld: false,
+ noWrap: true,
center: [-97, 38]
});
map.on('click', function (e) {
var coordinates = e.lngLat;
+ // Fix coordinates if map wrapped around
+ while (coordinates.lng < -180) {
+ coordinates.lng += 180;
+ }
+ while (coordinates.lng > 180) {
+ coordinates.lng -= 180;
+ }
try {
var words = FixPhrase.encode(coordinates.lat, coordinates.lng);
var popup = new mapboxgl.Popup();
- popup.setLngLat(coordinates);
- popup.setHTML("" + words + "
" + (Math.round(coordinates.lat * 10000) / 10000) + ", " + (Math.round(coordinates.lng * 10000) / 10000));
+ popup.setLngLat(e.lngLat);
+ popup.setHTML("" + words + "
" + (Math.round(coordinates.lat * 10000) / 10000) + ", " + (Math.round(coordinates.lng * 10000) / 10000));
popup.addTo(map);
+ map.flyTo({
+ center: e.lngLat,
+ zoom: Math.max(map.getZoom(), 14)
+ });
} catch (e) {
alert(e);
}
return;
-
+
// Example of accessing the PHP API instead of using JS
$.getJSON("lookup.php", {
latitude: coordinates.lat,