Skip to content

Commit

Permalink
docs: add versioned docs for version 0.0.1 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
josxha authored Sep 21, 2024
1 parent 2217ca7 commit e405d43
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const config: Config = {
},
{
label: 'Docs',
to: '/docs/supported-features',
to: '/docs/',
},
{
label: 'API Reference',
Expand Down
8 changes: 8 additions & 0 deletions docs/versioned_docs/version-0.0.1/features/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Features",
"position": 4,
"link": {
"type": "generated-index",
"description": "Dive in to the features MapLibre GL for Flutter provides."
}
}
41 changes: 41 additions & 0 deletions docs/versioned_docs/version-0.0.1/features/supported-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
sidebar_position: 1
---

# Supported Features

This is a broad orientation about what functionality could be added. The list
is orientated on MapLibre GL JS and the flutter-maplibre-gl map controller.
Some controller methods will be changed to provide a different annotation API.

| Feature | web | android | iOS | windows | macOS | linux |
|------------------------------------------|-----|---------|-----|---------|-------|-------|
| Map |||||||
| MapController |||||||
| maplibre-gl-js Web Controls |||||||
| Offline |||||||
| click callback |||||||
| long click callback |||||||
| secondary click callback |||||||
| controller.jumpTo() |||||||
| controller.flyTo() |||||||
| controller.addSource() |||||||
| controller.addLayer() |||||||
| controller.setMyLocationTrackingMode() |||||||
| controller.setMapLanguage() |||||||
| controller.toScreenLocation() |||||||
| controller.toLatLng() |||||||
| controller.getMetersPerPixelAtLatitude() |||||||

#### Legend

- ✅ implemented
- ❌ not (yet) implemented
- ➖ not supported

Support for windows, macOS and linux is currently not possible because of the
lack of platform views of these platforms.

- Windows: https://github.com/flutter/flutter/issues/31713
- MacOS: https://github.com/flutter/flutter/issues/41722
- Linux: https://github.com/flutter/flutter/issues/41724
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Getting Started",
"position": 2,
"link": {
"type": "generated-index",
"description": "Quick start guide"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
sidebar_position: 1
---

# Add Dependency

Add `maplibre` to your project by running this command:

```bash
flutter pub add maplibre
```

or add it directly as a dependency to your `pubspec.yaml` file and run
`flutter pub get`:

```yaml title="pubspec.yaml"
dependencies:
maplibre: ^0.0.1 # use the latest version found on pub.dev
```
You can find the latest version of the package on
[pub.dev](https://pub.dev/packages/maplibre) or here:
[![Pub Version](https://img.shields.io/pub/v/maplibre)](https://pub.dev/packages/maplibre)
55 changes: 55 additions & 0 deletions docs/versioned_docs/version-0.0.1/getting-started/setup-android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
sidebar_position: 3
---

# Setup Android

## Use a compatible Kotlin version

Ensure that you are using Kotlin version
**1.9.0** or newer. You can check the most recent Kotlin version on
[kotlinlang.org](https://kotlinlang.org/docs/releases.html#release-details).

#### (new) Gradle with a declarative plugins block

Open `android/settings.gradle` and set the Kotlin version like this:

```gradle title="android/settings.gradle"
plugins {
// ...
id "org.jetbrains.kotlin.android" version "1.9.0" apply false
}
```

In case you can't find the `plugins {}` block your app still uses the old apply
script method.

#### (old) In a legacy apply script gradle file:

Open `android/app/build.gradle` and set the Kotlin version like this:

```gradle title="android/app/build.gradle"
buildscript {
ext.kotlin_version = '1.9.0'
// ...
}
```

## Use the location feature

If you want to show the user's location on the map you need to add
the `ACCESS_COARSE_LOCATION` or `ACCESS_FINE_LOCATION` permission in the
application manifest `android/app/src/main/AndroidManifest.xml`.

```xml title="android/app/src/main/AndroidManifest.xml"

<manifest>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
</manifest>
```

Starting from Android API level 23 you also need to request it at runtime. This
plugin does not handle this for you. You can either use the flutter package
[location](https://pub.dev/packages/location)
or [permission_handler](https://pub.dev/packages/permission_handler) for this.
33 changes: 33 additions & 0 deletions docs/versioned_docs/version-0.0.1/getting-started/setup-web.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
sidebar_position: 4
---

# Setup Web

Include the following JavaScript and CSS files in the `<head>` tag of
your `web/index.html` file:

```html title="web/index.html"
<!DOCTYPE html>
<html>
<head>
<!-- other html -->

<!-- MapLibre -->
<script src='https://unpkg.com/maplibre-gl@^4.3/dist/maplibre-gl.js'></script>
<link href='https://unpkg.com/maplibre-gl@^4.3/dist/maplibre-gl.css'
rel='stylesheet'/>
</head>
</html>
```

`^4.3` ensures that your app will always use the latest version of
[maplibre-gl-js](https://github.com/maplibre/maplibre-gl-js) version 4 but not
suddenly
use an incompatible version.

If you want to always use the latest version use `latest` or use the full
version number like `4.3.0` if you want to use a specific version.

You can read about changes in maplibre-gl-js in
the [changelog file](https://github.com/maplibre/maplibre-gl-js/blob/main/CHANGELOG.md).
47 changes: 47 additions & 0 deletions docs/versioned_docs/version-0.0.1/getting-started/use-widget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
sidebar_position: 4
---

# Display your first map

Import the maplibre package and use the `MapLibreMap` widget to display a
map.

```dart
import 'package:flutter/material.dart';
import 'package:maplibre/maplibre.dart';
class MapScreen extends StatefulWidget {
const MapScreen({super.key});
@override
State createState() => FullMapState();
}
class MapScreenState extends State<MapScreen> {
MapController? _mapController;
@override
Widget build(BuildContext context) {
return Scaffold(
body: MapLibreMap(
onMapCreated: (controller) {
// Don't add additional annotations here,
// wait for the onStyleLoadedCallback.
_mapController = controller;
},
onStyleLoaded: () {
debugPrint('Map loaded 😎');
},
),
);
}
}
```

The result should look something like this:

![First map](../img/first_map.jpg)

If the map style isn't specified, the default MapLibre style is used. Use the
style of a tile provider or create and use your own map style.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions docs/versioned_docs/version-0.0.1/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
sidebar_position: 1
---

# Overview

This is the documentation for the unofficial MapLibre Flutter package.

flutter-maplibre provides bindings to MapLibre Native and MapLibre-GL-JS.

- [Getting started](getting-started/add-dependency)
- [Map Styles](map-styles)
52 changes: 52 additions & 0 deletions docs/versioned_docs/version-0.0.1/map-styles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
sidebar_position: 3
---

# Map Styles

Custom map styles can be used by setting the `style` parameter of the map
options like so:

```dart
Widget build() {
return MapLibreMap(
options: MapOptions(
style: 'https://demotiles.maplibre.org/style.json',
)
);
}
```

The following formats are supported:

1. Passing the URL of the map style. This should be a custom map style served
remotely using a URL that start with `http(s)://`.
2. Passing the style as a local file. create an JSON file in app directory (e.g.
ApplicationDocumentsDirectory). Set the style string to the absolute path of
this JSON file.
3. Passing the raw JSON of the map style. This is only supported on Android.

## Tile sources that require an API key

If your tile source requires an API key, it is recommended to directly append it
to the url as a query parameter.
For example:

```url
https://tiles.example.com/{z}/{x}/{y}.vector.pbf?api_key={your_key}
```

## Use existing styles

Every tile provider provides map styles that you can use. Note, that the style
needs to be compatible with the tile naming scheme. For example OpenMapTiles
styles used by MapTiler are not compatible with Protomaps tiles.

## Create a custom style

Map styles are defined in JSON. MapLibre offers a style editor
called [Maputnik](https://maplibre.org/maputnik)
that allows to customize existing styles or create a new style from scratch.
Other tile providers like MapBox have own editors you can use.

![Maputnik Editor](/img/maputnik.jpg)
8 changes: 8 additions & 0 deletions docs/versioned_sidebars/version-0.0.1-sidebars.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"docsSidebar": [
{
"type": "autogenerated",
"dirName": "."
}
]
}
3 changes: 3 additions & 0 deletions docs/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
"0.0.1"
]

0 comments on commit e405d43

Please sign in to comment.