Orientação gerada a partir de informações públicas. Apenas para referência.
Universe é um pacote Flutter que oferece uma maneira fácil e flexível de integrar mapas interativos em aplicativos Flutter, inspirado no Leaflet.js. Ele suporta renderização dinâmica de mapas, marcadores personalizados e interações por toque em múltiplas plataformas. Com uma API leve e design responsivo, permite que desenvolvedores criem experiências geoespaciais ricas com configuração mínima. O pacote é ideal para aplicativos que exigem visualização de mapas, rastreamento de localização ou representação de dados espaciais.
Casos de uso
Mapa interativo exibe
Recursos de aplicativo baseado em localização
Visualização de dados geoespaciais
Sobreposições de mapa e anotações
Interfaces de rastreamento em tempo real
Principais recursos
Compatibilidade multiplataforma
Camadas de mapa personalizáveis
Suporte a interação por toque
API leve e intuitiva
Suporte para marcadores e popups
Indicado para
Desenvolvedores de aplicativos móveis
Implementadores do recurso de geolocalização
Projetos de visualização de dados
Prototipagem de mapas interativos
Considerações
Requer acesso à internet para tiles de mapa
Recursos limitados de mapa offline
Dependente de provedores externos de mapas
Pode ser necessário ajuste de desempenho para grandes conjuntos de dados
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
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.