Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxBounds and setMaxBounds not working in globe projection #5474

Open
willymaps opened this issue Feb 7, 2025 · 0 comments
Open

maxBounds and setMaxBounds not working in globe projection #5474

willymaps opened this issue Feb 7, 2025 · 0 comments
Labels
bug Something isn't working globe Globe related issues PR is more than welcomed Extra attention is needed

Comments

@willymaps
Copy link

maplibre-gl-js version: 5.1.0

browser: Chrome 132.0.6834.160

Steps to Trigger Behavior

  1. Set maxBounds with a globe projection. Zoom is initially restricted but movement is possible outside of the bounds
  2. Do not use globe, movement is restricted as expected

Link to Demonstration

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Display a globe with a vector map</title>
    <meta property="og:description" content="Display a globe with a vector map." />
    <meta charset='utf-8'>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel='stylesheet' href='https://unpkg.com/maplibre-gl@5.1.0/dist/maplibre-gl.css' />
    <script src='https://unpkg.com/maplibre-gl@5.1.0/dist/maplibre-gl.js'></script>
    <style>
        body { margin: 0; padding: 0; }
        html, body, #map { height: 100%; }
    </style>
</head>
<body>
<div id="map"></div>
<script>

	const data = {
		"type": "FeatureCollection",
		"features": [
			{
				"type": "Feature",
				"properties": {},
				"geometry": {
					"coordinates": [0,0],
					"type": "Point"
				}
			}
		]
	}

    const style = {
        version: 8,
        sources: {},
        layers: [
            {
                id:'background',
                type:'background',
                paint: {
                    'background-color': '#111'
                }
            }
        ]
    }

    const map = new maplibregl.Map({
        container: 'map',
        style,
        zoom: 2,
        center:[0, 0],
		maxBounds: [
			[-15, -15],
			[15, 15]
		]
    });

    map.on('style.load', () => {

		map.setProjection({
			type: 'globe', // Set projection to globe
		});

       map.addSource('point-source', {
			type: 'geojson',
			data
	   })

	   map.addLayer({
			id: 'point-layer',
			type: 'circle',
			source: 'point-source',
			paint: {
				'circle-color': 'coral',
				'circle-radius': 100
			}

	   })
    });
</script>
</body>
</html>
@HarelM HarelM added bug Something isn't working PR is more than welcomed Extra attention is needed globe Globe related issues labels Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working globe Globe related issues PR is more than welcomed Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants