Jump to a series of locations

Use the jumpTo function to showcase multiple locations.

NPM module setup


npm install --save @maptiler/sdk
import { Map, MapStyle, config } from '@maptiler/sdk';
import '@maptiler/sdk/dist/maptiler-sdk.css';

config.apiKey = 'YOUR_MAPTILER_API_KEY_HERE';
const cities = {
    'type': 'FeatureCollection',
    'features': [
        {
            'type': 'Feature',
            'properties': {},
            'geometry': {
                'type': 'Point',
                'coordinates': [100.507, 13.745]
            }
        },
        {
            'type': 'Feature',
            'properties': {},
            'geometry': {
                'type': 'Point',
                'coordinates': [98.993, 18.793]
            }
        },
        {
            'type': 'Feature',
            'properties': {},
            'geometry': {
                'type': 'Point',
                'coordinates': [99.838, 19.924]
            }
        },
        {
            'type': 'Feature',
            'properties': {},
            'geometry': {
                'type': 'Point',
                'coordinates': [102.812, 17.408]
            }
        },
        {
            'type': 'Feature',
            'properties': {},
            'geometry': {
                'type': 'Point',
                'coordinates': [100.458, 7.001]
            }
        },
        {
            'type': 'Feature',
            'properties': {},
            'geometry': {
                'type': 'Point',
                'coordinates': [100.905, 12.935]
            }
        }
    ]
};

const map = new Map({
    container: 'map',
    style: MapStyle.STREETS, 
    center: [100.507, 13.745],
    zoom: 9
});

map.on('load', function () {
    cities.features.forEach(function (city, index) {
        setTimeout(function () {
            map.jumpTo({ center: city.geometry.coordinates });
        }, 2000 * index);
    });
});
Fit to the bounds of a lineString

Fit to the bounds of a lineString

Examples

Get the bounds of a lineString.

Fit a map to a bounding box

Fit a map to a bounding box

Examples

Fit map to a specific area using fitBounds method.

Fly to a location

Fly to a location

Examples

Smoothly interpolate between locations using the flyTo animation.

Create a story map, fly to a location based on the scroll position

Fly to a location based on the scroll position

Examples

Fly to locations on the map by scrolling.

Was this helpful?