universe 0.0.2-nullsafety.2 copy "universe: ^0.0.2-nullsafety.2" to clipboard
universe: ^0.0.2-nullsafety.2 copied to clipboard

outdated

The easy & flexible way to use interactive maps in Flutter. Inspired by Leaflet.js.

Universe #

The easy & flexible way to use interactive maps in Flutter.
Inspired by Leaflet.js.

universe

Getting Started #

Add dependency to your flutter project:

dependencies:
  universe: ^0.0.2-nullsafety.2
dependencies:
  universe:
    git: 
      url: git://github.com/salkuadrat/universe.git

Then run flutter pub get.

Add internet & location permissions to your AndroidManifest.xml.

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Example Project #

There is a complete example project in the example folder.
Check it out to learn the many use cases of using Universe library.

You can also try a working example with universe.apk.

Usage #

Inspired by the simplicity of Leaflet.js, now you can add maps functionality in your flutter project with as simple as adding this lines of code:

import 'package:universe/universe.dart';
U.OpenStreetMap(
  center: [-6.175329, 106.827253],
  type: OpenStreetMapType.HOT,
  zoom: 15,
)

Universe comes with built-in support for 3 maps provider: OpenStreetMap, Google Maps and MapBox.

OpenStreetMap #

U.OpenStreetMap(
  center: [-6.175329, 106.827253],
  type: OpenStreetMapType.Mapnik,
  zoom: 15,
)

Complete OpenStreetMap example

Google Maps #

U.GoogleMap(
  center: [-6.175329, 106.827253],
  type: GoogleMapType.Street,
  zoom: 15,
)

Complete Google Maps example

MapBox #

U.MapBox(
  accessToken: yourAccessTokenHere,
  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.

Complete MapBox example

Custom Map Provider #

We can also call U.Map directly to use maps from custom map providers. Here is an example of using custom map from OpenTopoMap.

U.Map(
  center: [51.555158, -0.108343],
  base: U.TileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
    attribution: 'Map data: &copy; OpenStreetMap contributors, SRTM | Map style: &copy; OpenTopoMap',
    maxZoom: 17,
  ),
)

Complete Custom Map example

Markers #

You can add marker to your maps with as simple as the following code:

U.OpenStreetMap(
  center: [51.555158, -0.108343],
  type: OpenStreetMapType.HOT,
  zoom: 15,
  markers: U.MarkerLayer([51.556669, -0.108123]),
)

Complete marker examples:

Simple Marker
Marker with Data
Multiple Marker
Multiple Marker with Different Styles
Multiple Marker with Data
Marker Icon
Marker Image
Marker SVG
Marker Widget
Tap to Add Marker

Live Maps #

U.OpenStreetMap(
  center: [51.555158, -0.108343],
  type: OpenStreetMapType.HOT,
  zoom: 15,
  live: true,
)

Complete live maps examples:

Default Live Map
Simple Live Map
Live Map with Location Marker

Live Maps Without AutoMoving #

The default behavior of Live Map will automatically move the center of the maps to user's current location. If we want to go live (always searching for user's current location and show location indicator to that location), but don't want to always move the center of the maps, we can use parameter moveWhenLive and set it 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,
)

Live Map without Auto Moving

Static Maps #

U.OpenStreetMap(
  center: [51.555158, -0.108343],
  type: OpenStreetMapType.Mapnik,
  zoom: 15,
  interactive: false,
)

Complete static maps examples:

Simple Static Map
Static Map with Marker
Static Map with Rotation

Other Examples #

Complex Map

Map with Initial Rotation
Map with Disabled Rotation
Map with MaxBounds
Map with FitBounds

MapController
MapController: Move Map
MapController: Zoom Map
MapController: Rotate Map
MapController: Find Location

Circle
Custom Circle
Multiple Circles
Multiple Circles with Different Styles
Circle with Data
Multiple Circles with Data

Polyline
Custom Polyline
Multiple Polylines
Multiple Polylines with Different Styles

Polygon
Multiple Polygons
Multiple Polygons with Diffrent Styles
Polygon with Data
Multiple Polygons with Data

Rectangle
Custom Rectangle
Multiple Rectangles
Multiple Rectangles with Different Styles
Rectangle with Data
Multiple Rectangles with Data

Image Overlay
Widget Overlay
Video Overlay

TileProvider: NetworkTileProvider
TileProvider: NetworkRetryTileProvider
TileProvider: CachedNetworkTileProvider
TileProvider: Offline AssetTileProvider

Map with Custom Compass
Map with Custom Locator
Map with Custom Scale Indicator
Map with Custom Location Indicator

Map Geolocator: Center by Address
Map Geolocator: Find LatLng by Address
Map Geolocator: Move by Address

85
likes
0
pub points
34%
popularity

Publisher

unverified uploader

The easy & flexible way to use interactive maps in Flutter. Inspired by Leaflet.js.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cached_network_image, curved_animation_controller, flutter, flutter_geocoder, flutter_svg, html_unescape, intl, location, logging, proj4dart, provider, tuple, vector_math, video_player

More

Packages that depend on universe