kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
587 stars 172 forks source link

Mobile - Marker draggable when zooming at max zoom. #187

Open jonboywhite opened 4 months ago

jonboywhite commented 4 months ago

Hi. I have a strange bug when viewing a map with a single marker on it and I zoom using a touchscreen to the maximum and move the map around with my fingers still zooming.

https://github.com/kartena/Proj4Leaflet/assets/69323398/97406c0f-d7ab-4d87-805a-6f0fef804481

Hopefully you can see the video above or attached.

I have used the basic code in tests from the repo and added a marker to it.

`const apiKey = '** MY KEY *****';

// Setup the EPSG:27700 (British National Grid) projection.
const crs = new L.Proj.CRS('EPSG:27700', '+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.15,0.247,0.842,-20.489 +units=m +no_defs', {
    resolutions: [ 896.0, 448.0, 224.0, 112.0, 56.0, 28.0, 14.0, 7.0, 3.5, 1.75 ],
    origin: [ -238375.0, 1376256.0 ]
});

// Transform coordinates.
const transformCoords = function(arr) {
    return proj4('EPSG:27700', 'EPSG:4326', arr).reverse();
};

// Initialize the map.
const mapOptions = {
    crs: crs,
    minZoom: 0,
    maxZoom: 9,
    center: [51.756463, -0.685633],
    zoom: 5,
    maxBounds: [
        transformCoords([ -238375.0, 0.0 ]),
        transformCoords([ 900000.0, 1376256.0 ])
    ],
    attributionControl: false,
    zoomSnap: 0
};

const map = L.map('map', mapOptions);

// Load and display ZXY tile layer on the map.
const basemap = L.tileLayer('https://api.os.uk/maps/raster/v1/zxy/Leisure_27700/{z}/{x}/{y}.png?key=' + apiKey).addTo(map);

var pMarker = L.icon({
    iconUrl: '/images/events/markers/orange-marker.png',
    iconSize:     [40, 52],
    iconAnchor:   [20, 52],
});
var marker = L.marker([51.756463, -0.685633], {icon: pMarker, draggable: false, interactive: false});

marker.addTo(map);`

Any help would be greatly appreciated.