Products
MapTiler Cloud
Maps Platform GeoData Hosting Weather Visualization Static maps API
MapTiler
Map Design Tool Search & Geocoding IP Geolocation API MapTiler SDK JS
server & data
Self-hosted Maps Map Server
Engine & Desktop
GeoData Processing
Company
News Careers About Us Open-source Contact
Pricing
Resources
Documentation Portal JavaScript SDK Android SDK iOS SDK API Client Library + CLI API Reference Tileset Schemas YouTube Channel Support
Search Products
MapTiler Cloud
Maps Platform GeoData Hosting Weather Visualization
MapTiler
Map Design Tool Search & Geocoding IP Geolocation API Static maps API MapTiler SDK JS
server & data
Self-hosted Maps Map Server
Engine & Desktop
GeoData Processing
Company
News Careers About Us Open-source Contact
Pricing Resources
Documentation Portal JavaScript SDK Android SDK iOS SDK API Client Library + CLI API Reference Tileset Schemas YouTube Channel Support
My Cloud
My Cloud
  1. Documentation
  2. SDK JS
  3. Examples
  4. Fit to the bounds of a lineString

Fit to the bounds of a lineString

Get the bounds of a LineString by passing its first coordinates to LngLatBounds and chaining extend to include the last coordinates.



Related examples

Fit a map to a bounding box

Fit a map to a bounding box

Example

Fit the map to a specific area, regardless of the pixel size of the map.

Restrict map panning to an area

Restrict map panning to an area

Example

Prevent a map from being panned to a different place by setting maxBounds.

Fly to a location

Fly to a location

Example

Use flyTo to smoothly interpolate between locations.

How to center map based on visitor’s country bounds

Center map by visitor’s country IP

Example

This tutorial shows how to center map based on the visitor’s country bounds using the MapTiler Geolocation API.

An extension of MapLibre GL JS
MapTiler SDK JS the easiest way for developers to integrate maps with their web applications and products is using our JavaScript Maps SDK

Examples

More than 100 examples

SDK JS Reference

  • Map
  • Map Styles
  • Markers and popups
  • Sources
  • Layers
  • Controls
  • Helpers
  • Coordinates
  • Events
  • User interaction handlers
  • Languages
  • Color Ramp
  • Config
  • API Client
  • Properties and options
  • Types

SDK Modules

  • 3D JS
  • Augmented reality (AR)
  • Elevation Profile
  • Geocoding
  • Marker Layout
  • Weather JS

Video tutorials

  • video tutorial about sdk-js
  • More video tutorials

JS Frameworks

  • Angular
  • React
  • Svelte
  • Vue.js
  • Vite

Other maps libraries

  • MapTiler SDK JS
  • Leaflet
  • OpenLayers
  • Deck.gl
  • Cesium

Other libraries

  • Unreal
  • Unity

Module Usage

  • MapTiler SDK JS
  • Leaflet
  • OpenLayers
  • MapLibre GL JS
  • React component
  • Svelte component
  • Vanilla JS

Module Reference

  • API Reference
  • Types and interfaces

Follow us on

Products
Maps API Geocoding Map designers tool GeoData hosting Static map IP Geolocation API Coordinates API Data processing Weather visualization MapTiler SDK Self-hosting Server Self-hosting Data
Maps & data
Streets Satellite Basic Light Dark Outdoor Winter 3D Terrain Countries MapTiler planet Attribution-free map Map preview Showcases & Tools
Usage
Transportation Weather Real Estate Aviation News & Media Government Mapbox alternative Google Maps API alternative Maps in videos Maps for games Custom coordinate systems Augmented reality maps Elections
Documentation
Tutorials API Reference Web SDK Android SDK iOS SDK Tileset Schemas YouTube channel Bug report
Company
News Jobs About Us Become a Partner Open-source Press Contact Cookie settings

©  2024  MapTiler. All rights reserved. Privacy & Terms.