Universe는 Leaflet.js를 영감으로 삼아 Flutter 애플리케이션에 인터랙티브 지도를 쉽게 유연하게 통합할 수 있도록 해주는 Flutter 패키지입니다. 동적 지도 렌더링, 사용자 정의 마커 및 여러 플랫폼에서의 터치 상호작용을 지원합니다. 가벼운 API와 반응형 디자인을 통해 개발자는 최소한의 설정으로 풍부한 지리공간 경험을 구축할 수 있습니다. 지도 시각화, 위치 추적 또는 공간 데이터 표현이 필요한 앱에 적합합니다.
사용 사례
인터랙티브 지도 표시
위치 기반 앱 기능
지오스페이셜 데이터 시각화
지도 오버레이 및 주석
실시간 추적 인터페이스
주요 기능
크로스 플랫폼 호환성
사용자 정의 지도 레이어
터치 상호작용 지원
경량이고 직관적인 API
마커 및 팝업 지원
적합한 대상
모바일 앱 개발자
지오로케이션 기능 구현자
데이터 시각화 프로젝트
인터랙티브 지도 프로토타이핑
고려 사항
지도 타일을 위해 인터넷 연결이 필요합니다
제한된 오프라인 지도 기능
외부 지도 제공업체에 의존
대규모 데이터 세트에 대한 성능 튜닝이 필요할 수 있습니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Universe
The easy & flexible way to use interactive maps in Flutter.
Supports OpenStreetMap, Google Maps, MapBox and more.
// List of available OpenStreetMapType// OSM MapnikOpenStreetMapType.Mapnik// OSM GermanyOpenStreetMapType.DE
// OSM SwitzerlandOpenStreetMapType.CH
// OSM FranceOpenStreetMapType.France// Humanitarian OSMOpenStreetMapType.HOT
// OSM BretonOpenStreetMapType.BZH
U.MapBox(
// get your access token from https://account.mapbox.com/access-tokens/
accessToken: '',
center: [-6.175329, 106.827253],
type: MapBoxType.Street,
zoom: 15,
)
You can get your own MapBox access token from here. Please always use your own access token in your projects.
// List of available MapBoxTypeMapBoxType.BasicMapBoxType.StreetMapBoxType.SatelliteMapBoxType.HybridMapBoxType.OutdoorsMapBoxType.DarkMapBoxType.LightMapBoxType.Bright
We can create maps with multiple tile layers. Here is an example of using Humanitarian OpenStreetMap combined with map tiles from SafeCast and OpenRailwayMap.
The default behavior of Live Map is always move the center of the maps to user's current location.
If you want to go live (always searching for user's current location and show location indicator to that location), but don't want to move the center of the maps, you can set parameter moveWhenLive to false.
U.GoogleMap(
type: GoogleMapType.Street,
center: [-6.169976, 106.830979],
zoom: 16,
live: true,
// moveWhenLive: false will make the map live (constantly search for user location),// set the location indicator to current user location, but does not // move the center of the maps automatically to that location.// moveWhenLive has default value set to true
moveWhenLive: false,
)
And use that controller to listen the positionStream to get current position and current zoom of our map. We can also programmatically move, zoom, rotate or find location using the map controller.
// listen everytime the map data changes (move or zoom)
_mapController.positionStream?.listen((data) {
// current center of the map// print(data.center); // current zoom level of the map// print(data.zoom);
});
Here is a simple example of painting a rectangle to universe maps.
U.OpenStreetMap(
center: [51.555015, -0.108331],
zoom: 16,
// by default, RectangleLayer will use style from theme primaryColor
rectangles: U.RectangleLayer(
[
[51.554488, -0.108964], // latlng of bottom left corner
[51.555682, -0.107580], // latlng of top right corner
],
),
)
Here is an example of painting an image overlay to universe maps.
U.OpenStreetMap(
center: [-6.175329, 106.827253],
zoom: 15,
images: [
U.ImageOverlay(
// from url'http://img.freeflagicons.com/thumb/background_with_square_parts/indonesia/indonesia_640.png',
// can use bounds from all 4 corners
bounds: [
[-6.180143, 106.823504],
[-6.180344, 106.828948],
[-6.17162, 106.82938],
[-6.171958, 106.823674],
],
fit: BoxFit.cover,
),
U.ImageOverlay(
// from assets'assets/startrek.png',
// can use bounds from only 2 corners
bounds: [
[-6.17098, 106.825514], // latlng of bottom left corner
[-6.167775, 106.822867], // latlng of top right corner
],
)
],
)
Universe maps come with default controls: compass, locator, scale and location indicator. But we can override this controls with our own controls to make it align with our app theme.