diff --git a/.gitignore b/.gitignore
index c530f7be0..17c0893ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,114 @@
-android/.classpath
-android/.project
-.packages
-.vscode/
+# Miscellaneous
+*.class
+*.lock
+*.log
+*.pyc
+*.swp
+.DS_Store
+.atom/
+.buildlog/
+.history
+.svn/
+
+# IntelliJ related
+*.iml
+*.ipr
+*.iws
.idea/
-android/.settings/org.eclipse.buildship.core.prefs
+# Visual Studio Code related
+.classpath
+.project
+.settings/
+.vscode/
+
+# Flutter repo-specific
+/bin/cache/
+/bin/mingit/
+/dev/benchmarks/mega_gallery/
+/dev/bots/.recipe_deps
+/dev/bots/android_tools/
+/dev/docs/doc/
+/dev/docs/flutter.docs.zip
+/dev/docs/lib/
+/dev/docs/pubspec.yaml
+/dev/integration_tests/**/xcuserdata
+/dev/integration_tests/**/Pods
+/packages/flutter/coverage/
+version
+
+# packages file containing multi-root paths
+.packages.generated
+
+# Flutter/Dart/Pub related
+**/doc/api/
+.dart_tool/
+.flutter-plugins
+.flutter-plugins-dependencies
+.packages
+.pub-cache/
+.pub/
+build/
+flutter_*.png
+linked_*.ds
+unlinked.ds
+unlinked_spec.ds
+
+# Android related
+**/android/**/gradle-wrapper.jar
+**/android/.gradle
+**/android/captures/
+**/android/gradlew
+**/android/gradlew.bat
+**/android/local.properties
+**/android/**/GeneratedPluginRegistrant.java
+**/android/key.properties
+*.jks
+
+# iOS/XCode related
+**/ios/**/*.mode1v3
+**/ios/**/*.mode2v3
+**/ios/**/*.moved-aside
+**/ios/**/*.pbxuser
+**/ios/**/*.perspectivev3
+**/ios/**/*sync/
+**/ios/**/.sconsign.dblite
+**/ios/**/.tags*
+**/ios/**/.vagrant/
+**/ios/**/DerivedData/
+**/ios/**/Icon?
+**/ios/**/Pods/
+**/ios/**/.symlinks/
+**/ios/**/profile
+**/ios/**/xcuserdata
+**/ios/.generated/
+**/ios/Flutter/App.framework
+**/ios/Flutter/Flutter.framework
+**/ios/Flutter/Flutter.podspec
+**/ios/Flutter/Generated.xcconfig
+**/ios/Flutter/app.flx
+**/ios/Flutter/app.zip
+**/ios/Flutter/flutter_assets/
+**/ios/Flutter/flutter_export_environment.sh
+**/ios/ServiceDefinitions.json
+**/ios/Runner/GeneratedPluginRegistrant.*
+
+# macOS
+**/macos/Flutter/GeneratedPluginRegistrant.swift
+**/macos/Flutter/Flutter-Debug.xcconfig
+**/macos/Flutter/Flutter-Release.xcconfig
+**/macos/Flutter/Flutter-Profile.xcconfig
+
+# Coverage
+coverage/
+
+# Symbols
+app.*.symbols
+
+# Exceptions to above rules.
+!**/ios/**/default.mode1v3
+!**/ios/**/default.mode2v3
+!**/ios/**/default.pbxuser
+!**/ios/**/default.perspectivev3
+!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
+!/dev/ci/**/Gemfile.lock
\ No newline at end of file
diff --git a/README.md b/README.md
index 24d692f2d..e8819b39b 100644
--- a/README.md
+++ b/README.md
@@ -8,6 +8,7 @@ embedded interactive and customizable vector maps inside a Flutter widget by emb
![screenshot.png](screenshot.png)
## Install
+
This project is available on [pub.dev](https://pub.dev/packages/mapbox_gl), follow the [instructions](https://flutter.dev/docs/development/packages-and-plugins/using-packages#adding-a-package-dependency-to-an-app) to integrate a package into your flutter application.
## :new: :new: Who's using this SDK :new: :new:
@@ -28,40 +29,69 @@ This project uses Mapbox vector tiles, which requires a Mapbox account and a Map
> **Even if you do not use Mapbox vector tiles but vector tiles from a different source (like self-hosted tiles) with this plugin, you will need to specify any non-empty string as Access Token as explained below!**
##### Android
+
Add Mapbox read token value in the application manifest ```android/app/src/main/AndroidManifest.xml:```
-```
```
-#### iOS
+##### iOS
+
Add these lines to your Info.plist
-```
+```xml
io.flutter.embedded_views_preview
MGLMapboxAccessToken
YOUR_TOKEN_HERE
```
+
If you access your users' location, you should also add the following key to your Info.plist to explain why you need access to their location data:
-```
+
+```xml
NSLocationWhenInUseUsageDescription
[Your explanation here]
```
+
Mapbox [recommends](https://docs.mapbox.com/help/tutorials/first-steps-ios-sdk/#display-the-users-location) the explanation "Shows your location on the map and helps improve the map".
+
+##### Web
+
+Add mapbox-gl.js library in the `
` of your html page:
+
+```html
+
+ ...
+
+
+```
+
+Add your `accessToken` in a script tag at the end of your body:
+
+```html
+
+ ...
+
+
+```
+
## Supported API
-| Feature | Android | iOS |
-| ------ | ------ | ----- |
-| Style | :white_check_mark: | :white_check_mark: |
-| Camera | :white_check_mark: | :white_check_mark: |
-| Gesture | :white_check_mark: | :white_check_mark: |
-| User Location | :white_check_mark: | :white_check_mark: |
-| Symbol | :white_check_mark: | :white_check_mark: |
-| Circle | :white_check_mark: | :white_check_mark: |
-| Line | :white_check_mark: | :white_check_mark: |
-| Fill | | |
+| Feature | Android | iOS | Web |
+| ------ | ------ | ----- | ----- |
+| Style | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| Camera | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| Gesture | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| User Location | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| Symbol | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| Circle | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| Line | :white_check_mark: | :white_check_mark: | :white_check_mark: |
+| Fill | | | |
## Offline Sideloading
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
new file mode 100644
index 000000000..f11e4c8d0
--- /dev/null
+++ b/example/android/app/src/debug/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/android/app/src/main/kotlin/com/mapbox/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/mapbox/example/MainActivity.kt
new file mode 100644
index 000000000..d6fa3f0b5
--- /dev/null
+++ b/example/android/app/src/main/kotlin/com/mapbox/example/MainActivity.kt
@@ -0,0 +1,12 @@
+package com.mapbox.example
+
+import androidx.annotation.NonNull;
+import io.flutter.embedding.android.FlutterActivity
+import io.flutter.embedding.engine.FlutterEngine
+import io.flutter.plugins.GeneratedPluginRegistrant
+
+class MainActivity: FlutterActivity() {
+ override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
+ GeneratedPluginRegistrant.registerWith(flutterEngine);
+ }
+}
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
new file mode 100644
index 000000000..f11e4c8d0
--- /dev/null
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
new file mode 100644
index 000000000..e96ef602b
--- /dev/null
+++ b/example/ios/.gitignore
@@ -0,0 +1,32 @@
+*.mode1v3
+*.mode2v3
+*.moved-aside
+*.pbxuser
+*.perspectivev3
+**/*sync/
+.sconsign.dblite
+.tags*
+**/.vagrant/
+**/DerivedData/
+Icon?
+**/Pods/
+**/.symlinks/
+profile
+xcuserdata
+**/.generated/
+Flutter/App.framework
+Flutter/Flutter.framework
+Flutter/Flutter.podspec
+Flutter/Generated.xcconfig
+Flutter/app.flx
+Flutter/app.zip
+Flutter/flutter_assets/
+Flutter/flutter_export_environment.sh
+ServiceDefinitions.json
+Runner/GeneratedPluginRegistrant.*
+
+# Exceptions to above rules.
+!default.mode1v3
+!default.mode2v3
+!default.pbxuser
+!default.perspectivev3
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index c53701713..4b3022495 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -10,10 +10,6 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
1C318FD9FE81A3CF826CB6E0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E9C618A260D4CE68F2F89632 /* Pods_Runner.framework */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
- 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
- 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
- 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
- 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
@@ -28,8 +24,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
- 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
- 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@@ -41,7 +35,6 @@
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
33EB4B753D90FC406A268B9A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
- 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
647A9CC8EAD456F68D57F590 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
77F62DAA39FA47F19A7FF5D8 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
@@ -49,7 +42,6 @@
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
- 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
@@ -64,8 +56,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
- 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
1C318FD9FE81A3CF826CB6E0 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -84,9 +74,7 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
- 3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
- 9740EEBA1CF902C7004384FC /* Flutter.framework */,
9740EEB21CF90195004384FC /* Debug.xcconfig */,
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
9740EEB31CF90195004384FC /* Generated.xcconfig */,
@@ -232,7 +220,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
+ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
61A6A5795B0A22D55417D672 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
@@ -262,9 +250,12 @@
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework",
"${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/Mapbox.framework.dSYM",
- "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/F6FDF133-0198-394E-9C8F-5043F94B4790.bcsymbolmap",
- "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/B4615DAE-86F8-35AB-B4D1-B1F1420E374A.bcsymbolmap",
+ "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap",
+ "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap",
+ "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap",
+ "${PODS_ROOT}/Mapbox-iOS-SDK/dynamic/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap",
"${BUILT_PRODUCTS_DIR}/MapboxAnnotationExtension/MapboxAnnotationExtension.framework",
+ "${BUILT_PRODUCTS_DIR}/MapboxMobileEvents/MapboxMobileEvents.framework",
"${BUILT_PRODUCTS_DIR}/location/location.framework",
"${BUILT_PRODUCTS_DIR}/mapbox_gl/mapbox_gl.framework",
);
@@ -273,9 +264,12 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Mapbox.framework",
"${DWARF_DSYM_FOLDER_PATH}/Mapbox.framework.dSYM",
- "${BUILT_PRODUCTS_DIR}/F6FDF133-0198-394E-9C8F-5043F94B4790.bcsymbolmap",
- "${BUILT_PRODUCTS_DIR}/B4615DAE-86F8-35AB-B4D1-B1F1420E374A.bcsymbolmap",
+ "${BUILT_PRODUCTS_DIR}/4794199C-B164-3A2D-A3B4-553B7D49EDD5.bcsymbolmap",
+ "${BUILT_PRODUCTS_DIR}/097AD13C-9FDA-310F-8B76-64CB67B06A27.bcsymbolmap",
+ "${BUILT_PRODUCTS_DIR}/491A77E9-7DBC-3309-A93C-BADAE0DDBC6E.bcsymbolmap",
+ "${BUILT_PRODUCTS_DIR}/3F114CA8-302D-327F-87C3-670E0EC63C9A.bcsymbolmap",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxAnnotationExtension.framework",
+ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MapboxMobileEvents.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/location.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/mapbox_gl.framework",
);
@@ -335,7 +329,6 @@
/* Begin XCBuildConfiguration section */
249021D3217E4FDB00AE95B9 /* Profile */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
@@ -409,7 +402,6 @@
};
97C147031CF9000F007C117D /* Debug */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
@@ -465,7 +457,6 @@
};
97C147041CF9000F007C117D /* Release */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 000000000..18d981003
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
similarity index 77%
rename from example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
rename to example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
index 949b67898..f9b0d7c5e 100644
--- a/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -2,7 +2,7 @@
- BuildSystemType
- Original
+ PreviewsEnabled
+
diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift
new file mode 100644
index 000000000..70693e4a8
--- /dev/null
+++ b/example/ios/Runner/AppDelegate.swift
@@ -0,0 +1,13 @@
+import UIKit
+import Flutter
+
+@UIApplicationMain
+@objc class AppDelegate: FlutterAppDelegate {
+ override func application(
+ _ application: UIApplication,
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
+ ) -> Bool {
+ GeneratedPluginRegistrant.register(with: self)
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
+ }
+}
diff --git a/example/ios/Runner/Runner-Bridging-Header.h b/example/ios/Runner/Runner-Bridging-Header.h
new file mode 100644
index 000000000..308a2a560
--- /dev/null
+++ b/example/ios/Runner/Runner-Bridging-Header.h
@@ -0,0 +1 @@
+#import "GeneratedPluginRegistrant.h"
diff --git a/example/lib/generated_plugin_registrant.dart b/example/lib/generated_plugin_registrant.dart
new file mode 100644
index 000000000..6f912e320
--- /dev/null
+++ b/example/lib/generated_plugin_registrant.dart
@@ -0,0 +1,16 @@
+//
+// Generated file. Do not edit.
+//
+
+// ignore: unused_import
+import 'dart:ui';
+
+import 'package:mapbox_gl_web/mapbox_gl_web.dart';
+
+import 'package:flutter_web_plugins/flutter_web_plugins.dart';
+
+// ignore: public_member_api_docs
+void registerPlugins(PluginRegistry registry) {
+ MapboxMapPlugin.registerWith(registry.registrarFor(MapboxMapPlugin));
+ registry.registerMessageHandler();
+}
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 98269e2df..d2ecf286d 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:location/location.dart';
import 'package:mapbox_gl_example/full_map.dart';
@@ -29,12 +30,13 @@ final List _allPages = [
class MapsDemo extends StatelessWidget {
void _pushPage(BuildContext context, ExamplePage page) async {
- final location = Location();
- final hasPermissions = await location.hasPermission();
- if (hasPermissions != PermissionStatus.GRANTED) {
- await location.requestPermission();
+ if (!kIsWeb) {
+ final location = Location();
+ final hasPermissions = await location.hasPermission();
+ if (hasPermissions != PermissionStatus.GRANTED) {
+ await location.requestPermission();
+ }
}
-
Navigator.of(context).push(MaterialPageRoute(
builder: (_) => Scaffold(
appBar: AppBar(title: Text(page.title)),
diff --git a/example/macos/.gitignore b/example/macos/.gitignore
new file mode 100644
index 000000000..d2fd37723
--- /dev/null
+++ b/example/macos/.gitignore
@@ -0,0 +1,6 @@
+# Flutter-related
+**/Flutter/ephemeral/
+**/Pods/
+
+# Xcode-related
+**/xcuserdata/
diff --git a/example/macos/Podfile b/example/macos/Podfile
new file mode 100644
index 000000000..d60ec7102
--- /dev/null
+++ b/example/macos/Podfile
@@ -0,0 +1,82 @@
+platform :osx, '10.11'
+
+# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
+ENV['COCOAPODS_DISABLE_STATS'] = 'true'
+
+project 'Runner', {
+ 'Debug' => :debug,
+ 'Profile' => :release,
+ 'Release' => :release,
+}
+
+def parse_KV_file(file, separator='=')
+ file_abs_path = File.expand_path(file)
+ if !File.exists? file_abs_path
+ return [];
+ end
+ pods_ary = []
+ skip_line_start_symbols = ["#", "/"]
+ File.foreach(file_abs_path) { |line|
+ next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
+ plugin = line.split(pattern=separator)
+ if plugin.length == 2
+ podname = plugin[0].strip()
+ path = plugin[1].strip()
+ podpath = File.expand_path("#{path}", file_abs_path)
+ pods_ary.push({:name => podname, :path => podpath});
+ else
+ puts "Invalid plugin specification: #{line}"
+ end
+ }
+ return pods_ary
+end
+
+def pubspec_supports_macos(file)
+ file_abs_path = File.expand_path(file)
+ if !File.exists? file_abs_path
+ return false;
+ end
+ File.foreach(file_abs_path) { |line|
+ return true if line =~ /^\s*macos:/
+ }
+ return false
+end
+
+target 'Runner' do
+ use_frameworks!
+ use_modular_headers!
+
+ # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
+ # referring to absolute paths on developers' machines.
+ ephemeral_dir = File.join('Flutter', 'ephemeral')
+ symlink_dir = File.join(ephemeral_dir, '.symlinks')
+ symlink_plugins_dir = File.join(symlink_dir, 'plugins')
+ system("rm -rf #{symlink_dir}")
+ system("mkdir -p #{symlink_plugins_dir}")
+
+ # Flutter Pods
+ generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig'))
+ if generated_xcconfig.empty?
+ puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
+ end
+ generated_xcconfig.map { |p|
+ if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
+ symlink = File.join(symlink_dir, 'flutter')
+ File.symlink(File.dirname(p[:path]), symlink)
+ pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path]))
+ end
+ }
+
+ # Plugin Pods
+ plugin_pods = parse_KV_file('../.flutter-plugins')
+ plugin_pods.map { |p|
+ symlink = File.join(symlink_plugins_dir, p[:name])
+ File.symlink(p[:path], symlink)
+ if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml'))
+ pod p[:name], :path => File.join(symlink, 'macos')
+ end
+ }
+end
+
+# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
+install! 'cocoapods', :disable_input_output_paths => true
diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj
new file mode 100644
index 000000000..331479d39
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/project.pbxproj
@@ -0,0 +1,596 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 51;
+ objects = {
+
+/* Begin PBXAggregateTarget section */
+ 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = {
+ isa = PBXAggregateTarget;
+ buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */;
+ buildPhases = (
+ 33CC111E2044C6BF0003C045 /* ShellScript */,
+ );
+ dependencies = (
+ );
+ name = "Flutter Assemble";
+ productName = FLX;
+ };
+/* End PBXAggregateTarget section */
+
+/* Begin PBXBuildFile section */
+ 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; };
+ 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; };
+ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
+ 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
+ 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
+ 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
+ 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
+ D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 33CC10E52044A3C60003C045 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 33CC111A2044C6BA0003C045;
+ remoteInfo = FLX;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 33CC110E2044A8840003C045 /* Bundle Framework */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 10;
+ files = (
+ D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
+ 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
+ );
+ name = "Bundle Framework";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; };
+ 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; };
+ 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
+ 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
+ 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; };
+ 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; };
+ 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; };
+ 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; };
+ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; };
+ 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; };
+ 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; };
+ 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
+ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; };
+ 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; };
+ 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; };
+ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; };
+ 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; };
+ D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 33CC10EA2044A3C60003C045 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
+ 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 33BA886A226E78AF003329D5 /* Configs */ = {
+ isa = PBXGroup;
+ children = (
+ 33E5194F232828860026EE4D /* AppInfo.xcconfig */,
+ 9740EEB21CF90195004384FC /* Debug.xcconfig */,
+ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
+ 333000ED22D3DE5D00554162 /* Warnings.xcconfig */,
+ );
+ path = Configs;
+ sourceTree = "";
+ };
+ 33CC10E42044A3C60003C045 = {
+ isa = PBXGroup;
+ children = (
+ 33FAB671232836740065AC1E /* Runner */,
+ 33CEB47122A05771004F2AC0 /* Flutter */,
+ 33CC10EE2044A3C60003C045 /* Products */,
+ D73912EC22F37F3D000D13A0 /* Frameworks */,
+ );
+ sourceTree = "";
+ };
+ 33CC10EE2044A3C60003C045 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 33CC10ED2044A3C60003C045 /* example.app */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ 33CC11242044D66E0003C045 /* Resources */ = {
+ isa = PBXGroup;
+ children = (
+ 33CC10F22044A3C60003C045 /* Assets.xcassets */,
+ 33CC10F42044A3C60003C045 /* MainMenu.xib */,
+ 33CC10F72044A3C60003C045 /* Info.plist */,
+ );
+ name = Resources;
+ path = ..;
+ sourceTree = "";
+ };
+ 33CEB47122A05771004F2AC0 /* Flutter */ = {
+ isa = PBXGroup;
+ children = (
+ 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */,
+ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
+ 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
+ 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
+ D73912EF22F37F9E000D13A0 /* App.framework */,
+ 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
+ );
+ path = Flutter;
+ sourceTree = "";
+ };
+ 33FAB671232836740065AC1E /* Runner */ = {
+ isa = PBXGroup;
+ children = (
+ 33CC10F02044A3C60003C045 /* AppDelegate.swift */,
+ 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */,
+ 33E51913231747F40026EE4D /* DebugProfile.entitlements */,
+ 33E51914231749380026EE4D /* Release.entitlements */,
+ 33CC11242044D66E0003C045 /* Resources */,
+ 33BA886A226E78AF003329D5 /* Configs */,
+ );
+ path = Runner;
+ sourceTree = "";
+ };
+ D73912EC22F37F3D000D13A0 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 33CC10EC2044A3C60003C045 /* Runner */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */;
+ buildPhases = (
+ 33CC10E92044A3C60003C045 /* Sources */,
+ 33CC10EA2044A3C60003C045 /* Frameworks */,
+ 33CC10EB2044A3C60003C045 /* Resources */,
+ 33CC110E2044A8840003C045 /* Bundle Framework */,
+ 3399D490228B24CF009A79C7 /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ 33CC11202044C79F0003C045 /* PBXTargetDependency */,
+ );
+ name = Runner;
+ productName = Runner;
+ productReference = 33CC10ED2044A3C60003C045 /* example.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 33CC10E52044A3C60003C045 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastSwiftUpdateCheck = 0920;
+ LastUpgradeCheck = 0930;
+ ORGANIZATIONNAME = "The Flutter Authors";
+ TargetAttributes = {
+ 33CC10EC2044A3C60003C045 = {
+ CreatedOnToolsVersion = 9.2;
+ LastSwiftMigration = 1100;
+ ProvisioningStyle = Automatic;
+ SystemCapabilities = {
+ com.apple.Sandbox = {
+ enabled = 1;
+ };
+ };
+ };
+ 33CC111A2044C6BA0003C045 = {
+ CreatedOnToolsVersion = 9.2;
+ ProvisioningStyle = Manual;
+ };
+ };
+ };
+ buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */;
+ compatibilityVersion = "Xcode 8.0";
+ developmentRegion = en;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 33CC10E42044A3C60003C045;
+ productRefGroup = 33CC10EE2044A3C60003C045 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 33CC10EC2044A3C60003C045 /* Runner */,
+ 33CC111A2044C6BA0003C045 /* Flutter Assemble */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 33CC10EB2044A3C60003C045 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */,
+ 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ 3399D490228B24CF009A79C7 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ );
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
+ };
+ 33CC111E2044C6BF0003C045 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ Flutter/ephemeral/FlutterInputs.xcfilelist,
+ );
+ inputPaths = (
+ Flutter/ephemeral/tripwire,
+ );
+ outputFileListPaths = (
+ Flutter/ephemeral/FlutterOutputs.xcfilelist,
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh\ntouch Flutter/ephemeral/tripwire\n";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 33CC10E92044A3C60003C045 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */,
+ 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */,
+ 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ 33CC11202044C79F0003C045 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */;
+ targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin PBXVariantGroup section */
+ 33CC10F42044A3C60003C045 /* MainMenu.xib */ = {
+ isa = PBXVariantGroup;
+ children = (
+ 33CC10F52044A3C60003C045 /* Base */,
+ );
+ name = MainMenu.xib;
+ path = Runner;
+ sourceTree = "";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ 338D0CE9231458BD00FA5F75 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_OPTIMIZATION_LEVEL = "-O";
+ };
+ name = Profile;
+ };
+ 338D0CEA231458BD00FA5F75 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Flutter/ephemeral",
+ );
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_VERSION = 5.0;
+ };
+ name = Profile;
+ };
+ 338D0CEB231458BD00FA5F75 /* Profile */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Manual;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Profile;
+ };
+ 33CC10F92044A3C60003C045 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ };
+ name = Debug;
+ };
+ 33CC10FA2044A3C60003C045 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu11;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ SWIFT_COMPILATION_MODE = wholemodule;
+ SWIFT_OPTIMIZATION_LEVEL = "-O";
+ };
+ name = Release;
+ };
+ 33CC10FC2044A3C60003C045 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Flutter/ephemeral",
+ );
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_VERSION = 5.0;
+ };
+ name = Debug;
+ };
+ 33CC10FD2044A3C60003C045 /* Release */ = {
+ isa = XCBuildConfiguration;
+ baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */;
+ buildSettings = {
+ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
+ CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements;
+ CODE_SIGN_STYLE = Automatic;
+ COMBINE_HIDPI_IMAGES = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Flutter/ephemeral",
+ );
+ INFOPLIST_FILE = Runner/Info.plist;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/../Frameworks",
+ );
+ PROVISIONING_PROFILE_SPECIFIER = "";
+ SWIFT_VERSION = 5.0;
+ };
+ name = Release;
+ };
+ 33CC111C2044C6BA0003C045 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Manual;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 33CC111D2044C6BA0003C045 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CODE_SIGN_STYLE = Automatic;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 33CC10F92044A3C60003C045 /* Debug */,
+ 33CC10FA2044A3C60003C045 /* Release */,
+ 338D0CE9231458BD00FA5F75 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 33CC10FC2044A3C60003C045 /* Debug */,
+ 33CC10FD2044A3C60003C045 /* Release */,
+ 338D0CEA231458BD00FA5F75 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 33CC111C2044C6BA0003C045 /* Debug */,
+ 33CC111D2044C6BA0003C045 /* Release */,
+ 338D0CEB231458BD00FA5F75 /* Profile */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 33CC10E52044A3C60003C045 /* Project object */;
+}
diff --git a/example/macos/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/example/macos/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 000000000..764c74b8d
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 000000000..18d981003
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
new file mode 100644
index 000000000..df12c333e
--- /dev/null
+++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/macos/Runner.xcworkspace/contents.xcworkspacedata b/example/macos/Runner.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 000000000..1d526a16e
--- /dev/null
+++ b/example/macos/Runner.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 000000000..18d981003
--- /dev/null
+++ b/example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift
new file mode 100644
index 000000000..d53ef6437
--- /dev/null
+++ b/example/macos/Runner/AppDelegate.swift
@@ -0,0 +1,9 @@
+import Cocoa
+import FlutterMacOS
+
+@NSApplicationMain
+class AppDelegate: FlutterAppDelegate {
+ override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
+ return true
+ }
+}
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
new file mode 100644
index 000000000..a2ec33f19
--- /dev/null
+++ b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
@@ -0,0 +1,68 @@
+{
+ "images" : [
+ {
+ "size" : "16x16",
+ "idiom" : "mac",
+ "filename" : "app_icon_16.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "16x16",
+ "idiom" : "mac",
+ "filename" : "app_icon_32.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "32x32",
+ "idiom" : "mac",
+ "filename" : "app_icon_32.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "32x32",
+ "idiom" : "mac",
+ "filename" : "app_icon_64.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "128x128",
+ "idiom" : "mac",
+ "filename" : "app_icon_128.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "128x128",
+ "idiom" : "mac",
+ "filename" : "app_icon_256.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "256x256",
+ "idiom" : "mac",
+ "filename" : "app_icon_256.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "256x256",
+ "idiom" : "mac",
+ "filename" : "app_icon_512.png",
+ "scale" : "2x"
+ },
+ {
+ "size" : "512x512",
+ "idiom" : "mac",
+ "filename" : "app_icon_512.png",
+ "scale" : "1x"
+ },
+ {
+ "size" : "512x512",
+ "idiom" : "mac",
+ "filename" : "app_icon_1024.png",
+ "scale" : "2x"
+ }
+ ],
+ "info" : {
+ "version" : 1,
+ "author" : "xcode"
+ }
+}
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
new file mode 100644
index 000000000..3c4935a7c
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
new file mode 100644
index 000000000..ed4cc1642
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
new file mode 100644
index 000000000..483be6138
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
new file mode 100644
index 000000000..bcbf36df2
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
new file mode 100644
index 000000000..9c0a65286
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
new file mode 100644
index 000000000..e71a72613
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ
diff --git a/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png
new file mode 100644
index 000000000..8a31fe2dd
Binary files /dev/null and b/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ
diff --git a/example/macos/Runner/Base.lproj/MainMenu.xib b/example/macos/Runner/Base.lproj/MainMenu.xib
new file mode 100644
index 000000000..537341abf
--- /dev/null
+++ b/example/macos/Runner/Base.lproj/MainMenu.xib
@@ -0,0 +1,339 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/macos/Runner/Configs/AppInfo.xcconfig b/example/macos/Runner/Configs/AppInfo.xcconfig
new file mode 100644
index 000000000..4fa23d759
--- /dev/null
+++ b/example/macos/Runner/Configs/AppInfo.xcconfig
@@ -0,0 +1,14 @@
+// Application-level settings for the Runner target.
+//
+// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the
+// future. If not, the values below would default to using the project name when this becomes a
+// 'flutter create' template.
+
+// The application's name. By default this is also the title of the Flutter window.
+PRODUCT_NAME = example
+
+// The application's bundle identifier
+PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.example
+
+// The copyright displayed in application information
+PRODUCT_COPYRIGHT = Copyright © 2020 com.mapbox. All rights reserved.
diff --git a/example/macos/Runner/Configs/Debug.xcconfig b/example/macos/Runner/Configs/Debug.xcconfig
new file mode 100644
index 000000000..36b0fd946
--- /dev/null
+++ b/example/macos/Runner/Configs/Debug.xcconfig
@@ -0,0 +1,2 @@
+#include "../../Flutter/Flutter-Debug.xcconfig"
+#include "Warnings.xcconfig"
diff --git a/example/macos/Runner/Configs/Release.xcconfig b/example/macos/Runner/Configs/Release.xcconfig
new file mode 100644
index 000000000..dff4f4956
--- /dev/null
+++ b/example/macos/Runner/Configs/Release.xcconfig
@@ -0,0 +1,2 @@
+#include "../../Flutter/Flutter-Release.xcconfig"
+#include "Warnings.xcconfig"
diff --git a/example/macos/Runner/Configs/Warnings.xcconfig b/example/macos/Runner/Configs/Warnings.xcconfig
new file mode 100644
index 000000000..42bcbf478
--- /dev/null
+++ b/example/macos/Runner/Configs/Warnings.xcconfig
@@ -0,0 +1,13 @@
+WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings
+GCC_WARN_UNDECLARED_SELECTOR = YES
+CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES
+CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE
+CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
+CLANG_WARN_PRAGMA_PACK = YES
+CLANG_WARN_STRICT_PROTOTYPES = YES
+CLANG_WARN_COMMA = YES
+GCC_WARN_STRICT_SELECTOR_MATCH = YES
+CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
+CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
+GCC_WARN_SHADOW = YES
+CLANG_WARN_UNREACHABLE_CODE = YES
diff --git a/example/macos/Runner/DebugProfile.entitlements b/example/macos/Runner/DebugProfile.entitlements
new file mode 100644
index 000000000..dddb8a30c
--- /dev/null
+++ b/example/macos/Runner/DebugProfile.entitlements
@@ -0,0 +1,12 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+ com.apple.security.cs.allow-jit
+
+ com.apple.security.network.server
+
+
+
diff --git a/example/macos/Runner/Info.plist b/example/macos/Runner/Info.plist
new file mode 100644
index 000000000..4789daa6a
--- /dev/null
+++ b/example/macos/Runner/Info.plist
@@ -0,0 +1,32 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ $(DEVELOPMENT_LANGUAGE)
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIconFile
+
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ $(FLUTTER_BUILD_NAME)
+ CFBundleVersion
+ $(FLUTTER_BUILD_NUMBER)
+ LSMinimumSystemVersion
+ $(MACOSX_DEPLOYMENT_TARGET)
+ NSHumanReadableCopyright
+ $(PRODUCT_COPYRIGHT)
+ NSMainNibFile
+ MainMenu
+ NSPrincipalClass
+ NSApplication
+
+
diff --git a/example/macos/Runner/MainFlutterWindow.swift b/example/macos/Runner/MainFlutterWindow.swift
new file mode 100644
index 000000000..2722837ec
--- /dev/null
+++ b/example/macos/Runner/MainFlutterWindow.swift
@@ -0,0 +1,15 @@
+import Cocoa
+import FlutterMacOS
+
+class MainFlutterWindow: NSWindow {
+ override func awakeFromNib() {
+ let flutterViewController = FlutterViewController.init()
+ let windowFrame = self.frame
+ self.contentViewController = flutterViewController
+ self.setFrame(windowFrame, display: true)
+
+ RegisterGeneratedPlugins(registry: flutterViewController)
+
+ super.awakeFromNib()
+ }
+}
diff --git a/example/macos/Runner/Release.entitlements b/example/macos/Runner/Release.entitlements
new file mode 100644
index 000000000..852fa1a47
--- /dev/null
+++ b/example/macos/Runner/Release.entitlements
@@ -0,0 +1,8 @@
+
+
+
+
+ com.apple.security.app-sandbox
+
+
+
diff --git a/example/web/favicon.png b/example/web/favicon.png
new file mode 100644
index 000000000..8aaa46ac1
Binary files /dev/null and b/example/web/favicon.png differ
diff --git a/example/web/icons/Icon-192.png b/example/web/icons/Icon-192.png
new file mode 100644
index 000000000..b749bfef0
Binary files /dev/null and b/example/web/icons/Icon-192.png differ
diff --git a/example/web/icons/Icon-512.png b/example/web/icons/Icon-512.png
new file mode 100644
index 000000000..88cfd48df
Binary files /dev/null and b/example/web/icons/Icon-512.png differ
diff --git a/example/web/index.html b/example/web/index.html
new file mode 100644
index 000000000..2263e5b74
--- /dev/null
+++ b/example/web/index.html
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ example
+
+
+
+
+
+
+
+
+
diff --git a/example/web/manifest.json b/example/web/manifest.json
new file mode 100644
index 000000000..c63800102
--- /dev/null
+++ b/example/web/manifest.json
@@ -0,0 +1,23 @@
+{
+ "name": "example",
+ "short_name": "example",
+ "start_url": ".",
+ "display": "minimal-ui",
+ "background_color": "#0175C2",
+ "theme_color": "#0175C2",
+ "description": "A new Flutter project.",
+ "orientation": "portrait-primary",
+ "prefer_related_applications": false,
+ "icons": [
+ {
+ "src": "icons/Icon-192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "icons/Icon-512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ]
+}
diff --git a/ios/Classes/MapboxMapController.swift b/ios/Classes/MapboxMapController.swift
index 0211472e3..4cca985fd 100644
--- a/ios/Classes/MapboxMapController.swift
+++ b/ios/Classes/MapboxMapController.swift
@@ -289,10 +289,14 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
guard let name = arguments["name"] as? String else { return }
//guard let length = arguments["length"] as? NSNumber else { return }
guard let bytes = arguments["bytes"] as? FlutterStandardTypedData else { return }
+ guard let sdf = arguments["sdf"] as? Bool else { return }
guard let data = bytes.data as? Data else{ return }
guard let image = UIImage(data: data) else { return }
-
- self.mapView.style?.setImage(image, forName: name)
+ if (sdf) {
+ self.mapView.style?.setImage(image.withRenderingMode(.alwaysTemplate), forName: name)
+ } else {
+ self.mapView.style?.setImage(image, forName: name)
+ }
result(nil)
default:
result(FlutterMethodNotImplemented)
@@ -414,7 +418,9 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
circleAnnotationController?.delegate = self
mapReadyResult?(nil)
+ print("asdasd\(channel)")
if let channel = channel {
+ print("asdasd2 ")
channel.invokeMethod("map#onStyleLoaded", arguments: nil)
}
}
diff --git a/lib/mapbox_gl.dart b/lib/mapbox_gl.dart
index b3ad16bbb..b856b363d 100644
--- a/lib/mapbox_gl.dart
+++ b/lib/mapbox_gl.dart
@@ -7,21 +7,33 @@ library mapbox_gl;
import 'dart:async';
import 'dart:math';
import 'dart:typed_data';
-import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart';
+
+export 'package:mapbox_gl_platform_interface/mapbox_gl_platform_interface.dart'
+ show
+ LatLng,
+ LatLngBounds,
+ CameraPosition,
+ CameraUpdate,
+ ArgumentCallbacks,
+ Symbol,
+ SymbolOptions,
+ CameraTargetBounds,
+ MinMaxZoomPreference,
+ MapboxStyles,
+ MyLocationTrackingMode,
+ MyLocationRenderMode,
+ Circle,
+ CircleOptions,
+ Line,
+ LineOptions;
part 'src/bitmap.dart';
-part 'src/callbacks.dart';
-part 'src/camera.dart';
part 'src/controller.dart';
part 'src/mapbox_map.dart';
-part 'src/location.dart';
-part 'src/symbol.dart';
-part 'src/line.dart';
-part 'src/circle.dart';
-part 'src/ui.dart';
-part 'src/global.dart';
\ No newline at end of file
+part 'src/global.dart';
diff --git a/lib/src/controller.dart b/lib/src/controller.dart
index 12c901f4f..dd090ef70 100644
--- a/lib/src/controller.dart
+++ b/lib/src/controller.dart
@@ -32,8 +32,7 @@ typedef void OnMapIdleCallback();
/// Line tap events can be received by adding callbacks to [onLineTapped].
/// Circle tap events can be received by adding callbacks to [onCircleTapped].
class MapboxMapController extends ChangeNotifier {
- MapboxMapController._(
- this._id, MethodChannel channel, CameraPosition initialCameraPosition,
+ MapboxMapController._(this._id, CameraPosition initialCameraPosition,
{this.onStyleLoadedCallback,
this.onMapClick,
this.onMapLongClick,
@@ -41,11 +40,87 @@ class MapboxMapController extends ChangeNotifier {
this.onCameraTrackingChanged,
this.onCameraIdle,
this.onMapIdle})
- : assert(_id != null),
- assert(channel != null),
- _channel = channel {
+ : assert(_id != null) {
_cameraPosition = initialCameraPosition;
- _channel.setMethodCallHandler(_handleMethodCall);
+
+ MapboxGlPlatform.instance.onInfoWindowTappedPlatform.add((symbolId) {
+ final Symbol symbol = _symbols[symbolId];
+ if (symbol != null) {
+ onInfoWindowTapped(symbol);
+ }
+ });
+
+ MapboxGlPlatform.instance.onSymbolTappedPlatform.add((symbolId) {
+ final Symbol symbol = _symbols[symbolId];
+ if (symbol != null) {
+ onSymbolTapped(symbol);
+ }
+ });
+
+ MapboxGlPlatform.instance.onLineTappedPlatform.add((lineId) {
+ final Line line = _lines[lineId];
+ if (line != null) {
+ onLineTapped(line);
+ }
+ });
+
+ MapboxGlPlatform.instance.onCircleTappedPlatform.add((circleId) {
+ final Circle circle = _circles[circleId];
+ if (circle != null) {
+ onCircleTapped(circle);
+ }
+ });
+
+ MapboxGlPlatform.instance.onCameraMoveStartedPlatform.add((_) {
+ _isCameraMoving = true;
+ notifyListeners();
+ });
+
+ MapboxGlPlatform.instance.onCameraMovePlatform.add((cameraPosition) {
+ _cameraPosition = cameraPosition;
+ notifyListeners();
+ });
+
+ MapboxGlPlatform.instance.onCameraIdlePlatform.add((_) {
+ _isCameraMoving = false;
+ notifyListeners();
+ });
+
+ MapboxGlPlatform.instance.onMapStyleLoadedPlatform.add((_) {
+ if (onStyleLoadedCallback != null) {
+ onStyleLoadedCallback();
+ }
+ });
+
+ MapboxGlPlatform.instance.onMapClickPlatform.add((dict) {
+ if (onMapClick != null) {
+ onMapClick(dict['point'], dict['latLng']);
+ }
+ });
+
+ MapboxGlPlatform.instance.onMapLongClickPlatform.add((dict) {
+ if (onMapLongClick != null) {
+ onMapLongClick(dict['point'], dict['latLng']);
+ }
+ });
+
+ MapboxGlPlatform.instance.onCameraTrackingChangedPlatform.add((mode) {
+ if (onCameraTrackingChanged != null) {
+ onCameraTrackingChanged(mode);
+ }
+ });
+
+ MapboxGlPlatform.instance.onCameraTrackingDismissedPlatform.add((_) {
+ if (onCameraTrackingDismissed != null) {
+ onCameraTrackingDismissed();
+ }
+ });
+
+ MapboxGlPlatform.instance.onMapIdlePlatform.add((_) {
+ if (onMapIdle != null) {
+ onMapIdle();
+ }
+ });
}
static Future init(
@@ -58,10 +133,8 @@ class MapboxMapController extends ChangeNotifier {
OnCameraIdleCallback onCameraIdle,
OnMapIdleCallback onMapIdle}) async {
assert(id != null);
- final MethodChannel channel =
- MethodChannel('plugins.flutter.io/mapbox_maps_$id');
- await channel.invokeMethod('map#waitForMap');
- return MapboxMapController._(id, channel, initialCameraPosition,
+ await MapboxGlPlatform.instance.initPlatform(id);
+ return MapboxMapController._(id, initialCameraPosition,
onStyleLoadedCallback: onStyleLoadedCallback,
onMapClick: onMapClick,
onMapLongClick: onMapLongClick,
@@ -71,8 +144,6 @@ class MapboxMapController extends ChangeNotifier {
onMapIdle: onMapIdle);
}
- final MethodChannel _channel;
-
final OnStyleLoadedCallback onStyleLoadedCallback;
final OnMapClickCallback onMapClick;
@@ -127,93 +198,12 @@ class MapboxMapController extends ChangeNotifier {
final int _id; //ignore: unused_field
- Future _handleMethodCall(MethodCall call) async {
- switch (call.method) {
- case 'infoWindow#onTap':
- final String symbolId = call.arguments['symbol'];
- final Symbol symbol = _symbols[symbolId];
- if (symbol != null) {
- onInfoWindowTapped(symbol);
- }
- break;
- case 'symbol#onTap':
- final String symbolId = call.arguments['symbol'];
- final Symbol symbol = _symbols[symbolId];
- if (symbol != null) {
- onSymbolTapped(symbol);
- }
- break;
- case 'line#onTap':
- final String lineId = call.arguments['line'];
- final Line line = _lines[lineId];
- if (line != null) {
- onLineTapped(line);
- }
- break;
- case 'circle#onTap':
- final String circleId = call.arguments['circle'];
- final Circle circle = _circles[circleId];
- if (circle != null) {
- onCircleTapped(circle);
- }
- break;
- case 'camera#onMoveStarted':
- _isCameraMoving = true;
- notifyListeners();
- break;
- case 'camera#onMove':
- _cameraPosition = CameraPosition.fromMap(call.arguments['position']);
- notifyListeners();
- break;
- case 'camera#onIdle':
- _isCameraMoving = false;
- if (onCameraIdle != null) {
- onCameraIdle();
- }
- notifyListeners();
- break;
- case 'map#onStyleLoaded':
- if (onStyleLoadedCallback != null) {
- onStyleLoadedCallback();
- }
- break;
- case 'map#onMapClick':
- final double x = call.arguments['x'];
- final double y = call.arguments['y'];
- final double lng = call.arguments['lng'];
- final double lat = call.arguments['lat'];
- if (onMapClick != null) {
- onMapClick(Point(x, y), LatLng(lat, lng));
- }
- break;
- case 'map#onMapLongClick':
- final double x = call.arguments['x'];
- final double y = call.arguments['y'];
- final double lng = call.arguments['lng'];
- final double lat = call.arguments['lat'];
- if (onMapLongClick != null) {
- onMapLongClick(Point(x, y), LatLng(lat, lng));
- }
- break;
- case 'map#onCameraTrackingChanged':
- if (onCameraTrackingChanged != null) {
- final int mode = call.arguments['mode'];
- onCameraTrackingChanged(MyLocationTrackingMode.values[mode]);
- }
- break;
- case 'map#onCameraTrackingDismissed':
- if (onCameraTrackingDismissed != null) {
- onCameraTrackingDismissed();
- }
- break;
- case 'map#onIdle':
- if (onMapIdle != null) {
- onMapIdle();
- }
- break;
- default:
- throw MissingPluginException();
- }
+ Widget buildView(
+ Map creationParams,
+ Function onPlatformViewCreated,
+ Set> gestureRecognizers) {
+ return MapboxGlPlatform.instance
+ .buildView(creationParams, onPlatformViewCreated, gestureRecognizers);
}
/// Updates configuration options of the map user interface.
@@ -224,13 +214,8 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes after listeners have been notified.
Future _updateMapOptions(Map optionsUpdate) async {
assert(optionsUpdate != null);
- final dynamic json = await _channel.invokeMethod(
- 'map#update',
- {
- 'options': optionsUpdate,
- },
- );
- _cameraPosition = CameraPosition.fromMap(json);
+ _cameraPosition =
+ await MapboxGlPlatform.instance.updateMapOptions(optionsUpdate);
notifyListeners();
}
@@ -240,12 +225,9 @@ class MapboxMapController extends ChangeNotifier {
/// platform side.
/// It returns true if the camera was successfully moved and false if the movement was canceled.
/// Note: this currently always returns immediately with a value of null on iOS
- Future animateCamera(CameraUpdate cameraUpdate,
- {Duration duration}) async {
- return await _channel.invokeMethod('camera#animate', {
- 'cameraUpdate': cameraUpdate._toJson(),
- 'duration': duration != null ? duration.inMilliseconds : null
- });
+ Future animateCamera(CameraUpdate cameraUpdate) async {
+ assert(cameraUpdate != null);
+ return MapboxGlPlatform.instance.animateCamera(cameraUpdate);
}
/// Instantaneously re-position the camera.
@@ -256,9 +238,7 @@ class MapboxMapController extends ChangeNotifier {
/// It returns true if the camera was successfully moved and false if the movement was canceled.
/// Note: this currently always returns immediately with a value of null on iOS
Future moveCamera(CameraUpdate cameraUpdate) async {
- return await _channel.invokeMethod('camera#move', {
- 'cameraUpdate': cameraUpdate._toJson(),
- });
+ return MapboxGlPlatform.instance.moveCamera(cameraUpdate);
}
/// Updates user location tracking mode.
@@ -267,10 +247,8 @@ class MapboxMapController extends ChangeNotifier {
/// platform side.
Future updateMyLocationTrackingMode(
MyLocationTrackingMode myLocationTrackingMode) async {
- await _channel
- .invokeMethod('map#updateMyLocationTrackingMode', {
- 'mode': myLocationTrackingMode.index,
- });
+ return MapboxGlPlatform.instance
+ .updateMyLocationTrackingMode(myLocationTrackingMode);
}
/// Updates the language of the map labels to match the device's language.
@@ -278,7 +256,7 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes after the change has been made on the
/// platform side.
Future matchMapLanguageWithDeviceDefault() async {
- await _channel.invokeMethod('map#matchMapLanguageWithDeviceDefault');
+ return MapboxGlPlatform.instance.matchMapLanguageWithDeviceDefault();
}
/// Updates the distance from the edges of the map view’s frame to the edges
@@ -294,15 +272,7 @@ class MapboxMapController extends ChangeNotifier {
/// platform side.
Future updateContentInsets(EdgeInsets insets,
[bool animated = false]) async {
- await _channel.invokeMethod('map#updateContentInsets', {
- 'bounds': {
- 'top': insets.top,
- 'left': insets.left,
- 'bottom': insets.bottom,
- 'right': insets.right,
- },
- 'animated': animated,
- });
+ return MapboxGlPlatform.instance.updateContentInsets(insets, animated);
}
/// Updates the language of the map labels to match the specified language.
@@ -311,9 +281,7 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes after the change has been made on the
/// platform side.
Future setMapLanguage(String language) async {
- await _channel.invokeMethod('map#setMapLanguage', {
- 'language': language,
- });
+ return MapboxGlPlatform.instance.setMapLanguage(language);
}
/// Enables or disables the collection of anonymized telemetry data.
@@ -321,9 +289,7 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes after the change has been made on the
/// platform side.
Future setTelemetryEnabled(bool enabled) async {
- await _channel.invokeMethod('map#setTelemetryEnabled', {
- 'enabled': enabled,
- });
+ return MapboxGlPlatform.instance.setTelemetryEnabled(enabled);
}
/// Retrieves whether collection of anonymized telemetry data is enabled.
@@ -331,7 +297,7 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes after the query has been made on the
/// platform side.
Future getTelemetryEnabled() async {
- return await _channel.invokeMethod('map#getTelemetryEnabled');
+ return MapboxGlPlatform.instance.getTelemetryEnabled();
}
/// Adds a symbol to the map, configured using the specified custom [options].
@@ -344,14 +310,8 @@ class MapboxMapController extends ChangeNotifier {
Future addSymbol(SymbolOptions options, [Map data]) async {
final SymbolOptions effectiveOptions =
SymbolOptions.defaultOptions.copyWith(options);
- final String symbolId = await _channel.invokeMethod(
- 'symbol#add',
- {
- 'options': effectiveOptions._toJson(),
- },
- );
- final Symbol symbol = Symbol(symbolId, effectiveOptions, data);
- _symbols[symbolId] = symbol;
+ final symbol = await MapboxGlPlatform.instance.addSymbol(effectiveOptions);
+ _symbols[symbol.id] = symbol;
notifyListeners();
return symbol;
}
@@ -365,13 +325,10 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once listeners have been notified.
Future updateSymbol(Symbol symbol, SymbolOptions changes) async {
assert(symbol != null);
- assert(_symbols[symbol._id] == symbol);
+ assert(_symbols[symbol.id] == symbol);
assert(changes != null);
- await _channel.invokeMethod('symbol#update', {
- 'symbol': symbol._id,
- 'options': changes._toJson(),
- });
- symbol._options = symbol._options.copyWith(changes);
+ await MapboxGlPlatform.instance.updateSymbol(symbol, changes);
+ symbol.options = symbol.options.copyWith(changes);
notifyListeners();
}
@@ -384,8 +341,8 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once listeners have been notified.
Future removeSymbol(Symbol symbol) async {
assert(symbol != null);
- assert(_symbols[symbol._id] == symbol);
- await _removeSymbol(symbol._id);
+ assert(_symbols[symbol.id] == symbol);
+ await _removeSymbol(symbol.id);
notifyListeners();
}
@@ -410,9 +367,7 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once the symbol has been removed from
/// [_symbols].
Future _removeSymbol(String id) async {
- await _channel.invokeMethod('symbol#remove', {
- 'symbol': id,
- });
+ await MapboxGlPlatform.instance.removeSymbol(id);
_symbols.remove(id);
}
@@ -426,14 +381,8 @@ class MapboxMapController extends ChangeNotifier {
Future addLine(LineOptions options, [Map data]) async {
final LineOptions effectiveOptions =
LineOptions.defaultOptions.copyWith(options);
- final String lineId = await _channel.invokeMethod(
- 'line#add',
- {
- 'options': effectiveOptions._toJson(),
- },
- );
- final Line line = Line(lineId, effectiveOptions, data);
- _lines[lineId] = line;
+ final line = await MapboxGlPlatform.instance.addLine(effectiveOptions);
+ _lines[line.id] = line;
notifyListeners();
return line;
}
@@ -447,13 +396,10 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once listeners have been notified.
Future updateLine(Line line, LineOptions changes) async {
assert(line != null);
- assert(_lines[line._id] == line);
+ assert(_lines[line.id] == line);
assert(changes != null);
- await _channel.invokeMethod('line#update', {
- 'line': line._id,
- 'options': changes._toJson(),
- });
- line._options = line._options.copyWith(changes);
+ await MapboxGlPlatform.instance.updateLine(line, changes);
+ line.options = line.options.copyWith(changes);
notifyListeners();
}
@@ -466,8 +412,8 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once listeners have been notified.
Future removeLine(Line line) async {
assert(line != null);
- assert(_lines[line._id] == line);
- await _removeLine(line._id);
+ assert(_lines[line.id] == line);
+ await _removeLine(line.id);
notifyListeners();
}
@@ -492,9 +438,7 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once the line has been removed from
/// [_lines].
Future _removeLine(String id) async {
- await _channel.invokeMethod('line#remove', {
- 'line': id,
- });
+ await MapboxGlPlatform.instance.removeLine(id);
_lines.remove(id);
}
@@ -508,14 +452,8 @@ class MapboxMapController extends ChangeNotifier {
Future addCircle(CircleOptions options, [Map data]) async {
final CircleOptions effectiveOptions =
CircleOptions.defaultOptions.copyWith(options);
- final String circleId = await _channel.invokeMethod(
- 'circle#add',
- {
- 'options': effectiveOptions._toJson(),
- },
- );
- final Circle circle = Circle(circleId, effectiveOptions, data);
- _circles[circleId] = circle;
+ final circle = await MapboxGlPlatform.instance.addCircle(effectiveOptions);
+ _circles[circle.id] = circle;
notifyListeners();
return circle;
}
@@ -529,13 +467,10 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once listeners have been notified.
Future updateCircle(Circle circle, CircleOptions changes) async {
assert(circle != null);
- assert(_circles[circle._id] == circle);
+ assert(_circles[circle.id] == circle);
assert(changes != null);
- await _channel.invokeMethod('circle#update', {
- 'circle': circle._id,
- 'options': changes._toJson(),
- });
- circle._options = circle._options.copyWith(changes);
+ await MapboxGlPlatform.instance.updateCircle(circle, changes);
+ circle.options = circle.options.copyWith(changes);
notifyListeners();
}
@@ -544,13 +479,9 @@ class MapboxMapController extends ChangeNotifier {
/// should use `getCircleLatLng()`
Future getCircleLatLng(Circle circle) async {
assert(circle != null);
- assert(_circles[circle._id] == circle);
- Map mapLatLng =
- await _channel.invokeMethod('circle#getGeometry', {
- 'circle': circle._id,
- });
- LatLng circleLatLng =
- new LatLng(mapLatLng['latitude'], mapLatLng['longitude']);
+ assert(_circles[circle.id] == circle);
+ final circleLatLng =
+ await MapboxGlPlatform.instance.getCircleLatLng(circle);
notifyListeners();
return circleLatLng;
}
@@ -564,8 +495,8 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once listeners have been notified.
Future removeCircle(Circle circle) async {
assert(circle != null);
- assert(_circles[circle._id] == circle);
- await _removeCircle(circle._id);
+ assert(_circles[circle.id] == circle);
+ await _removeCircle(circle.id);
notifyListeners();
}
@@ -590,107 +521,46 @@ class MapboxMapController extends ChangeNotifier {
/// The returned [Future] completes once the circle has been removed from
/// [_circles].
Future _removeCircle(String id) async {
- await _channel.invokeMethod('circle#remove', {
- 'circle': id,
- });
+ await MapboxGlPlatform.instance.removeCircle(id);
+
_circles.remove(id);
}
Future queryRenderedFeatures(
Point point, List layerIds, String filter) async {
- try {
- final Map reply = await _channel.invokeMethod(
- 'map#queryRenderedFeatures',
- {
- 'x': point.x,
- 'y': point.y,
- 'layerIds': layerIds,
- 'filter': filter,
- },
- );
- return reply['features'];
- } on PlatformException catch (e) {
- return new Future.error(e);
- }
+ return MapboxGlPlatform.instance
+ .queryRenderedFeatures(point, layerIds, filter);
}
Future queryRenderedFeaturesInRect(
Rect rect, List layerIds, String filter) async {
- try {
- final Map reply = await _channel.invokeMethod(
- 'map#queryRenderedFeatures',
- {
- 'left': rect.left,
- 'top': rect.top,
- 'right': rect.right,
- 'bottom': rect.bottom,
- 'layerIds': layerIds,
- 'filter': filter,
- },
- );
- return reply['features'];
- } on PlatformException catch (e) {
- return new Future.error(e);
- }
+ return MapboxGlPlatform.instance
+ .queryRenderedFeaturesInRect(rect, layerIds, filter);
}
Future invalidateAmbientCache() async {
- try {
- await _channel.invokeMethod('map#invalidateAmbientCache');
- return null;
- } on PlatformException catch (e) {
- return new Future.error(e);
- }
+ return MapboxGlPlatform.instance.invalidateAmbientCache();
}
/// Get last my location
///
/// Return last latlng, nullable
-
Future requestMyLocationLatLng() async {
- try {
- final Map reply = await _channel.invokeMethod(
- 'locationComponent#getLastLocation', null);
- double latitude = 0.0, longitude = 0.0;
- if (reply.containsKey("latitude") && reply["latitude"] != null) {
- latitude = double.parse(reply["latitude"].toString());
- }
- if (reply.containsKey("longitude") && reply["longitude"] != null) {
- longitude = double.parse(reply["longitude"].toString());
- }
- return LatLng(latitude, longitude);
- } on PlatformException catch (e) {
- return new Future.error(e);
- }
+ return MapboxGlPlatform.instance.requestMyLocationLatLng();
}
- ///This method returns the boundaries of the region currently displayed in the map.
+ /// This method returns the boundaries of the region currently displayed in the map.
Future getVisibleRegion() async {
- try {
- final Map reply =
- await _channel.invokeMethod('map#getVisibleRegion', null);
- LatLng southwest, northeast;
- if (reply.containsKey("sw")) {
- List coordinates = reply["sw"];
- southwest = LatLng(coordinates[0], coordinates[1]);
- }
- if (reply.containsKey("ne")) {
- List coordinates = reply["ne"];
- northeast = LatLng(coordinates[0], coordinates[1]);
- }
- return LatLngBounds(southwest: southwest, northeast: northeast);
- } on PlatformException catch (e) {
- return new Future.error(e);
- }
+ return MapboxGlPlatform.instance.getVisibleRegion();
}
/// Adds an image to the style currently displayed in the map, so that it can later be referred to by the provided name.
- ///
+ ///
/// This allows you to add an image to the currently displayed style once, and from there on refer to it e.g. in the [Symbol.iconImage] anytime you add a [Symbol] later on.
/// Set [sdf] to true if the image you add is an SDF image.
/// Returns after the image has successfully been added to the style.
/// Note: This can only be called after OnStyleLoadedCallback has been invoked and any added images will have to be re-added if a new style is loaded.
- ///
+ ///
/// Example: Adding an asset image and using it in a new symbol:
/// ```dart
/// Future addImageFromAsset() async{
@@ -705,7 +575,7 @@ class MapboxMapController extends ChangeNotifier {
/// );
/// }
/// ```
- ///
+ ///
/// Example: Adding a network image (with the http package) and using it in a new symbol:
/// ```dart
/// Future addImageFromUrl() async{
@@ -720,19 +590,6 @@ class MapboxMapController extends ChangeNotifier {
/// }
/// ```
Future addImage(String name, Uint8List bytes, [bool sdf = false]) {
- try {
- return _channel.invokeMethod('style#addImage', {
- "name": name,
- "bytes": bytes,
- "length": bytes.length,
- "sdf": sdf
- });
- } on PlatformException catch (e) {
- return new Future.error(e);
- }
+ return MapboxGlPlatform.instance.addImage(name, bytes, sdf);
}
-
-
-
-
}
diff --git a/lib/src/mapbox_map.dart b/lib/src/mapbox_map.dart
index c18b00af9..a57d9a1b6 100644
--- a/lib/src/mapbox_map.dart
+++ b/lib/src/mapbox_map.dart
@@ -161,29 +161,11 @@ class _MapboxMapState extends State {
@override
Widget build(BuildContext context) {
final Map creationParams = {
- 'initialCameraPosition': widget.initialCameraPosition?._toMap(),
+ 'initialCameraPosition': widget.initialCameraPosition?.toMap(),
'options': _MapboxMapOptions.fromWidget(widget).toMap(),
};
- if (defaultTargetPlatform == TargetPlatform.android) {
- return AndroidView(
- viewType: 'plugins.flutter.io/mapbox_gl',
- onPlatformViewCreated: onPlatformViewCreated,
- gestureRecognizers: widget.gestureRecognizers,
- creationParams: creationParams,
- creationParamsCodec: const StandardMessageCodec(),
- );
- } else if (defaultTargetPlatform == TargetPlatform.iOS) {
- return UiKitView(
- viewType: 'plugins.flutter.io/mapbox_gl',
- onPlatformViewCreated: onPlatformViewCreated,
- gestureRecognizers: widget.gestureRecognizers,
- creationParams: creationParams,
- creationParamsCodec: const StandardMessageCodec(),
- );
- }
-
- return Text(
- '$defaultTargetPlatform is not yet supported by the maps plugin');
+ return MapboxGlPlatform.instance.buildView(
+ creationParams, onPlatformViewCreated, widget.gestureRecognizers);
}
@override
@@ -268,7 +250,7 @@ class _MapboxMapOptions {
logoViewMargins: map.logoViewMargins,
compassViewPosition: map.compassViewPosition,
compassViewMargins: map.compassViewMargins,
- attributionButtonMargins: map.attributionButtonMargins
+ attributionButtonMargins: map.attributionButtonMargins,
);
}
@@ -322,9 +304,9 @@ class _MapboxMapOptions {
}
addIfNonNull('compassEnabled', compassEnabled);
- addIfNonNull('cameraTargetBounds', cameraTargetBounds?._toJson());
+ addIfNonNull('cameraTargetBounds', cameraTargetBounds?.toJson());
addIfNonNull('styleString', styleString);
- addIfNonNull('minMaxZoomPreference', minMaxZoomPreference?._toJson());
+ addIfNonNull('minMaxZoomPreference', minMaxZoomPreference?.toJson());
addIfNonNull('rotateGesturesEnabled', rotateGesturesEnabled);
addIfNonNull('scrollGesturesEnabled', scrollGesturesEnabled);
addIfNonNull('tiltGesturesEnabled', tiltGesturesEnabled);
@@ -336,12 +318,15 @@ class _MapboxMapOptions {
addIfNonNull('logoViewMargins', pointToArray(logoViewMargins));
addIfNonNull('compassViewPosition', compassViewPosition?.index);
addIfNonNull('compassViewMargins', pointToArray(compassViewMargins));
- addIfNonNull('attributionButtonMargins', pointToArray(attributionButtonMargins));
+ addIfNonNull(
+ 'attributionButtonMargins', pointToArray(attributionButtonMargins));
return optionsMap;
}
Map updatesMap(_MapboxMapOptions newOptions) {
final Map prevOptionsMap = toMap();
- return newOptions.toMap()..removeWhere((String key, dynamic value) => prevOptionsMap[key] == value);
+ return newOptions.toMap()
+ ..removeWhere(
+ (String key, dynamic value) => prevOptionsMap[key] == value);
}
}
diff --git a/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart
new file mode 100644
index 000000000..0abe3163a
--- /dev/null
+++ b/mapbox_gl_platform_interface/lib/mapbox_gl_platform_interface.dart
@@ -0,0 +1,19 @@
+library mapbox_gl_platform_interface;
+
+import 'dart:math';
+import 'dart:typed_data';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/gestures.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:meta/meta.dart' show required, visibleForTesting;
+
+part 'src/callbacks.dart';
+part 'src/camera.dart';
+part 'src/circle.dart';
+part 'src/line.dart';
+part 'src/location.dart';
+part 'src/method_channel_mapbox_gl.dart';
+part 'src/symbol.dart';
+part 'src/ui.dart';
+part 'src/mapbox_gl_platform_interface.dart';
diff --git a/lib/src/callbacks.dart b/mapbox_gl_platform_interface/lib/src/callbacks.dart
similarity index 97%
rename from lib/src/callbacks.dart
rename to mapbox_gl_platform_interface/lib/src/callbacks.dart
index 85d746a82..e375f2fef 100644
--- a/lib/src/callbacks.dart
+++ b/mapbox_gl_platform_interface/lib/src/callbacks.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
/// Callback function taking a single argument.
typedef void ArgumentCallback(T argument);
diff --git a/lib/src/camera.dart b/mapbox_gl_platform_interface/lib/src/camera.dart
similarity index 94%
rename from lib/src/camera.dart
rename to mapbox_gl_platform_interface/lib/src/camera.dart
index d6b407433..747086ddf 100644
--- a/lib/src/camera.dart
+++ b/mapbox_gl_platform_interface/lib/src/camera.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
/// The position of the map "camera", the view point from which the world is
/// shown in the map view. Aggregates the camera's [target] geographical
@@ -51,9 +51,9 @@ class CameraPosition {
/// will be silently clamped to the supported range.
final double zoom;
- dynamic _toMap() => {
+ dynamic toMap() => {
'bearing': bearing,
- 'target': target._toJson(),
+ 'target': target.toJson(),
'tilt': tilt,
'zoom': zoom,
};
@@ -98,14 +98,14 @@ class CameraUpdate {
/// Returns a camera update that moves the camera to the specified position.
static CameraUpdate newCameraPosition(CameraPosition cameraPosition) {
return CameraUpdate._(
- ['newCameraPosition', cameraPosition._toMap()],
+ ['newCameraPosition', cameraPosition.toMap()],
);
}
/// Returns a camera update that moves the camera target to the specified
/// geographical location.
static CameraUpdate newLatLng(LatLng latLng) {
- return CameraUpdate._(['newLatLng', latLng._toJson()]);
+ return CameraUpdate._(['newLatLng', latLng.toJson()]);
}
/// Returns a camera update that transforms the camera so that the specified
@@ -115,7 +115,7 @@ class CameraUpdate {
static CameraUpdate newLatLngBounds(LatLngBounds bounds, double padding) {
return CameraUpdate._([
'newLatLngBounds',
- bounds._toList(),
+ bounds.toList(),
padding,
]);
}
@@ -124,7 +124,7 @@ class CameraUpdate {
/// geographical location and zoom level.
static CameraUpdate newLatLngZoom(LatLng latLng, double zoom) {
return CameraUpdate._(
- ['newLatLngZoom', latLng._toJson(), zoom],
+ ['newLatLngZoom', latLng.toJson(), zoom],
);
}
@@ -180,7 +180,7 @@ class CameraUpdate {
static CameraUpdate bearingTo(double bearing) {
return CameraUpdate._(['bearingTo', bearing]);
}
-
+
/// Returns a camera update that sets the camera bearing.
static CameraUpdate tiltTo(double tilt) {
return CameraUpdate._(['tiltTo', tilt]);
@@ -188,5 +188,5 @@ class CameraUpdate {
final dynamic _json;
- dynamic _toJson() => _json;
+ dynamic toJson() => _json;
}
diff --git a/lib/src/circle.dart b/mapbox_gl_platform_interface/lib/src/circle.dart
similarity index 92%
rename from lib/src/circle.dart
rename to mapbox_gl_platform_interface/lib/src/circle.dart
index 9d738f267..01815ae85 100644
--- a/lib/src/circle.dart
+++ b/mapbox_gl_platform_interface/lib/src/circle.dart
@@ -4,29 +4,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
class Circle {
- @visibleForTesting
- Circle(this._id, this._options, [this._data]);
+ Circle(this._id, this.options, [this._data]);
/// A unique identifier for this circle.
///
/// The identifier is an arbitrary unique string.
final String _id;
String get id => _id;
-
-
- CircleOptions _options;
final Map _data;
Map get data => _data;
+
/// The circle configuration options most recently applied programmatically
/// via the map controller.
///
/// The returned value does not reflect any changes made to the circle through
/// touch events. Add listeners to the owning map controller to track those.
- CircleOptions get options => _options;
+ CircleOptions options;
}
/// Configuration options for [Circle] instances.
@@ -79,7 +76,7 @@ class CircleOptions {
);
}
- dynamic _toJson() {
+ dynamic toJson() {
final Map json = {};
void addIfPresent(String fieldName, dynamic value) {
@@ -95,7 +92,7 @@ class CircleOptions {
addIfPresent('circleStrokeWidth', circleStrokeWidth);
addIfPresent('circleStrokeColor', circleStrokeColor);
addIfPresent('circleStrokeOpacity', circleStrokeOpacity);
- addIfPresent('geometry', geometry?._toJson());
+ addIfPresent('geometry', geometry?.toJson());
addIfPresent('draggable', draggable);
return json;
}
diff --git a/lib/src/line.dart b/mapbox_gl_platform_interface/lib/src/line.dart
similarity index 91%
rename from lib/src/line.dart
rename to mapbox_gl_platform_interface/lib/src/line.dart
index 0832f9bd4..376ac1f78 100644
--- a/lib/src/line.dart
+++ b/mapbox_gl_platform_interface/lib/src/line.dart
@@ -4,11 +4,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
class Line {
- @visibleForTesting
- Line(this._id, this._options, [this._data]);
+ Line(this._id, this.options, [this._data]);
/// A unique identifier for this line.
///
@@ -18,17 +17,15 @@ class Line {
String get id => _id;
final Map _data;
-
- Map get data => _data;
- LineOptions _options;
+ Map get data => _data;
/// The line configuration options most recently applied programmatically
/// via the map controller.
///
/// The returned value does not reflect any changes made to the line through
/// touch events. Add listeners to the owning map controller to track those.
- LineOptions get options => _options;
+ LineOptions options;
}
/// Configuration options for [Line] instances.
@@ -84,7 +81,7 @@ class LineOptions {
);
}
- dynamic _toJson() {
+ dynamic toJson() {
final Map json = {};
void addIfPresent(String fieldName, dynamic value) {
@@ -101,7 +98,8 @@ class LineOptions {
addIfPresent('lineOffset', lineOffset);
addIfPresent('lineBlur', lineBlur);
addIfPresent('linePattern', linePattern);
- addIfPresent('geometry', geometry?.map((LatLng latLng) => latLng._toJson())?.toList());
+ addIfPresent('geometry',
+ geometry?.map((LatLng latLng) => latLng.toJson())?.toList());
addIfPresent('draggable', draggable);
return json;
}
diff --git a/lib/src/location.dart b/mapbox_gl_platform_interface/lib/src/location.dart
similarity index 95%
rename from lib/src/location.dart
rename to mapbox_gl_platform_interface/lib/src/location.dart
index 4f33b7b49..617943453 100644
--- a/lib/src/location.dart
+++ b/mapbox_gl_platform_interface/lib/src/location.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
/// A pair of latitude and longitude coordinates, stored as degrees.
class LatLng {
@@ -26,7 +26,7 @@ class LatLng {
/// The longitude in degrees between -180.0 (inclusive) and 180.0 (exclusive).
final double longitude;
- dynamic _toJson() {
+ dynamic toJson() {
return [latitude, longitude];
}
@@ -73,8 +73,8 @@ class LatLngBounds {
/// The northeast corner of the rectangle.
final LatLng northeast;
- dynamic _toList() {
- return [southwest._toJson(), northeast._toJson()];
+ dynamic toList() {
+ return [southwest.toJson(), northeast.toJson()];
}
@visibleForTesting
diff --git a/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart
new file mode 100644
index 000000000..86abc69e7
--- /dev/null
+++ b/mapbox_gl_platform_interface/lib/src/mapbox_gl_platform_interface.dart
@@ -0,0 +1,179 @@
+// ignore_for_file: unnecessary_getters_setters
+
+part of mapbox_gl_platform_interface;
+
+abstract class MapboxGlPlatform {
+ static MapboxGlPlatform _instance = MethodChannelMapboxGl();
+
+ final ArgumentCallbacks onInfoWindowTappedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onSymbolTappedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onLineTappedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onCircleTappedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onCameraMoveStartedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onCameraMovePlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onCameraIdlePlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onMapStyleLoadedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks> onMapClickPlatform =
+ ArgumentCallbacks>();
+
+ final ArgumentCallbacks> onMapLongClickPlatform =
+ ArgumentCallbacks>();
+
+ final ArgumentCallbacks
+ onCameraTrackingChangedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onCameraTrackingDismissedPlatform =
+ ArgumentCallbacks();
+
+ final ArgumentCallbacks onMapIdlePlatform = ArgumentCallbacks();
+
+ /// The default instance of [MapboxGlPlatform] to use.
+ ///
+ /// Defaults to [MethodChannelMapboxGl].
+ static MapboxGlPlatform get instance => _instance;
+
+ /// Platform-specific plugins should set this with their own platform-specific
+ /// class that extends [MapboxGlPlatform] when they register themselves.
+ static set instance(MapboxGlPlatform instance) {
+ _instance = instance;
+ }
+
+ Future initPlatform(int id) async {
+ throw UnimplementedError('initPlatform() has not been implemented.');
+ }
+
+ Widget buildView(
+ Map creationParams,
+ Function onPlatformViewCreated,
+ Set> gestureRecognizers) {
+ throw UnimplementedError('buildView() has not been implemented.');
+ }
+
+ Future updateMapOptions(
+ Map optionsUpdate) async {
+ throw UnimplementedError('updateMapOptions() has not been implemented.');
+ }
+
+ Future animateCamera(CameraUpdate cameraUpdate) async {
+ throw UnimplementedError('animateCamera() has not been implemented.');
+ }
+
+ Future moveCamera(CameraUpdate cameraUpdate) async {
+ throw UnimplementedError('moveCamera() has not been implemented.');
+ }
+
+ Future updateMyLocationTrackingMode(
+ MyLocationTrackingMode myLocationTrackingMode) async {
+ throw UnimplementedError(
+ 'updateMyLocationTrackingMode() has not been implemented.');
+ }
+
+ Future matchMapLanguageWithDeviceDefault() async {
+ throw UnimplementedError(
+ 'matchMapLanguageWithDeviceDefault() has not been implemented.');
+ }
+
+ Future updateContentInsets(EdgeInsets insets, bool animated) async {
+ throw UnimplementedError('updateContentInsets() has not been implemented.');
+ }
+
+ Future setMapLanguage(String language) async {
+ throw UnimplementedError('setMapLanguage() has not been implemented.');
+ }
+
+ Future setTelemetryEnabled(bool enabled) async {
+ throw UnimplementedError('setTelemetryEnabled() has not been implemented.');
+ }
+
+ Future getTelemetryEnabled() async {
+ throw UnimplementedError('getTelemetryEnabled() has not been implemented.');
+ }
+
+ Future addSymbol(SymbolOptions options, [Map data]) async {
+ throw UnimplementedError('addSymbol() has not been implemented.');
+ }
+
+ Future updateSymbol(Symbol symbol, SymbolOptions changes) async {
+ throw UnimplementedError('updateSymbol() has not been implemented.');
+ }
+
+ Future removeSymbol(String symbolId) async {
+ throw UnimplementedError('removeSymbol() has not been implemented.');
+ }
+
+ Future addLine(LineOptions options, [Map data]) async {
+ throw UnimplementedError('addLine() has not been implemented.');
+ }
+
+ Future updateLine(Line line, LineOptions changes) async {
+ throw UnimplementedError('updateLine() has not been implemented.');
+ }
+
+ Future removeLine(String lineId) async {
+ throw UnimplementedError('removeLine() has not been implemented.');
+ }
+
+ Future addCircle(CircleOptions options, [Map data]) async {
+ throw UnimplementedError('addCircle() has not been implemented.');
+ }
+
+ Future updateCircle(Circle circle, CircleOptions changes) async {
+ throw UnimplementedError('updateCircle() has not been implemented.');
+ }
+
+ Future getCircleLatLng(Circle circle) async {
+ throw UnimplementedError('getCircleLatLng() has not been implemented.');
+ }
+
+ Future removeCircle(String circleId) async {
+ throw UnimplementedError('removeCircle() has not been implemented.');
+ }
+
+ Future queryRenderedFeatures(
+ Point point, List layerIds, String filter) async {
+ throw UnimplementedError(
+ 'queryRenderedFeatures() has not been implemented.');
+ }
+
+ Future queryRenderedFeaturesInRect(
+ Rect rect, List layerIds, String filter) async {
+ throw UnimplementedError(
+ 'queryRenderedFeaturesInRect() has not been implemented.');
+ }
+
+ Future invalidateAmbientCache() async {
+ throw UnimplementedError(
+ 'invalidateAmbientCache() has not been implemented.');
+ }
+
+ Future requestMyLocationLatLng() async {
+ throw UnimplementedError(
+ 'requestMyLocationLatLng() has not been implemented.');
+ }
+
+ Future getVisibleRegion() async {
+ throw UnimplementedError('getVisibleRegion() has not been implemented.');
+ }
+
+ Future addImage(String name, Uint8List bytes,
+ [bool sdf = false]) async {
+ throw UnimplementedError('addImage() has not been implemented.');
+ }
+}
diff --git a/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart
new file mode 100644
index 000000000..7afab7c4a
--- /dev/null
+++ b/mapbox_gl_platform_interface/lib/src/method_channel_mapbox_gl.dart
@@ -0,0 +1,372 @@
+part of mapbox_gl_platform_interface;
+
+class MethodChannelMapboxGl extends MapboxGlPlatform {
+ MethodChannel _channel;
+
+ Future _handleMethodCall(MethodCall call) async {
+ switch (call.method) {
+ case 'infoWindow#onTap':
+ final String symbolId = call.arguments['symbol'];
+ if (symbolId != null) {
+ onInfoWindowTappedPlatform(symbolId);
+ }
+ break;
+ case 'symbol#onTap':
+ final String symbolId = call.arguments['symbol'];
+ if (symbolId != null) {
+ onSymbolTappedPlatform(symbolId);
+ }
+ break;
+ case 'line#onTap':
+ final String lineId = call.arguments['line'];
+ if (lineId != null) {
+ onLineTappedPlatform(lineId);
+ }
+ break;
+ case 'circle#onTap':
+ final String circleId = call.arguments['circle'];
+ if (circleId != null) {
+ onCircleTappedPlatform(circleId);
+ }
+ break;
+ case 'camera#onMoveStarted':
+ onCameraMoveStartedPlatform(null);
+ break;
+ case 'camera#onMove':
+ final CameraPosition cameraPosition =
+ CameraPosition.fromMap(call.arguments['position']);
+ onCameraMovePlatform(cameraPosition);
+ break;
+ case 'camera#onIdle':
+ onCameraIdlePlatform(null);
+ break;
+ case 'map#onStyleLoaded':
+ onMapStyleLoadedPlatform(null);
+ break;
+ case 'map#onMapClick':
+ final double x = call.arguments['x'];
+ final double y = call.arguments['y'];
+ final double lng = call.arguments['lng'];
+ final double lat = call.arguments['lat'];
+ onMapClickPlatform(
+ {'point': Point(x, y), 'latLng': LatLng(lat, lng)});
+ break;
+ case 'map#onMapLongClick':
+ final double x = call.arguments['x'];
+ final double y = call.arguments['y'];
+ final double lng = call.arguments['lng'];
+ final double lat = call.arguments['lat'];
+ onMapLongClickPlatform(
+ {'point': Point(x, y), 'latLng': LatLng(lat, lng)});
+
+ break;
+ case 'map#onCameraTrackingChanged':
+ final int mode = call.arguments['mode'];
+ onCameraTrackingChangedPlatform(MyLocationTrackingMode.values[mode]);
+ break;
+ case 'map#onCameraTrackingDismissed':
+ onCameraTrackingDismissedPlatform(null);
+ break;
+ case 'map#onIdle':
+ onMapIdlePlatform(null);
+ break;
+ default:
+ throw MissingPluginException();
+ }
+ }
+
+ @override
+ Future initPlatform(int id) async {
+ assert(id != null);
+ _channel = MethodChannel('plugins.flutter.io/mapbox_maps_$id');
+ await _channel.invokeMethod('map#waitForMap');
+ _channel.setMethodCallHandler(_handleMethodCall);
+ }
+
+ @override
+ Widget buildView(
+ Map creationParams,
+ Function onPlatformViewCreated,
+ Set> gestureRecognizers) {
+ if (defaultTargetPlatform == TargetPlatform.android) {
+ return AndroidView(
+ viewType: 'plugins.flutter.io/mapbox_gl',
+ onPlatformViewCreated: onPlatformViewCreated,
+ gestureRecognizers: gestureRecognizers,
+ creationParams: creationParams,
+ creationParamsCodec: const StandardMessageCodec(),
+ );
+ } else if (defaultTargetPlatform == TargetPlatform.iOS) {
+ return UiKitView(
+ viewType: 'plugins.flutter.io/mapbox_gl',
+ onPlatformViewCreated: onPlatformViewCreated,
+ gestureRecognizers: gestureRecognizers,
+ creationParams: creationParams,
+ creationParamsCodec: const StandardMessageCodec(),
+ );
+ }
+ return Text(
+ '$defaultTargetPlatform is not yet supported by the maps plugin');
+ }
+
+ @override
+ Future updateMapOptions(
+ Map optionsUpdate) async {
+ final dynamic json = await _channel.invokeMethod(
+ 'map#update',
+ {
+ 'options': optionsUpdate,
+ },
+ );
+ return CameraPosition.fromMap(json);
+ }
+
+ @override
+ Future animateCamera(cameraUpdate) async {
+ return await _channel.invokeMethod('camera#animate', {
+ 'cameraUpdate': cameraUpdate.toJson(),
+ });
+ }
+
+ @override
+ Future moveCamera(CameraUpdate cameraUpdate) async {
+ return await _channel.invokeMethod('camera#move', {
+ 'cameraUpdate': cameraUpdate.toJson(),
+ });
+ }
+
+ @override
+ Future updateMyLocationTrackingMode(
+ MyLocationTrackingMode myLocationTrackingMode) async {
+ await _channel
+ .invokeMethod('map#updateMyLocationTrackingMode', {
+ 'mode': myLocationTrackingMode.index,
+ });
+ }
+
+ @override
+ Future matchMapLanguageWithDeviceDefault() async {
+ await _channel.invokeMethod('map#matchMapLanguageWithDeviceDefault');
+ }
+
+ @override
+ Future updateContentInsets(EdgeInsets insets, bool animated) async {
+ await _channel.invokeMethod('map#updateContentInsets', {
+ 'bounds': {
+ 'top': insets.top,
+ 'left': insets.left,
+ 'bottom': insets.bottom,
+ 'right': insets.right,
+ },
+ 'animated': animated,
+ });
+ }
+
+ @override
+ Future setMapLanguage(String language) async {
+ await _channel.invokeMethod('map#setMapLanguage', {
+ 'language': language,
+ });
+ }
+
+ @override
+ Future setTelemetryEnabled(bool enabled) async {
+ await _channel.invokeMethod('map#setTelemetryEnabled', {
+ 'enabled': enabled,
+ });
+ }
+
+ @override
+ Future getTelemetryEnabled() async {
+ return await _channel.invokeMethod('map#getTelemetryEnabled');
+ }
+
+ @override
+ Future addSymbol(SymbolOptions options, [Map data]) async {
+ final String symbolId = await _channel.invokeMethod(
+ 'symbol#add',
+ {
+ 'options': options.toJson(),
+ },
+ );
+ return Symbol(symbolId, options, data);
+ }
+
+ @override
+ Future updateSymbol(Symbol symbol, SymbolOptions changes) async {
+ await _channel.invokeMethod('symbol#update', {
+ 'symbol': symbol.id,
+ 'options': changes.toJson(),
+ });
+ }
+
+ @override
+ Future removeSymbol(String symbolId) async {
+ await _channel.invokeMethod('symbol#remove', {
+ 'symbol': symbolId,
+ });
+ }
+
+ @override
+ Future addLine(LineOptions options, [Map data]) async {
+ final String lineId = await _channel.invokeMethod(
+ 'line#add',
+ {
+ 'options': options.toJson(),
+ },
+ );
+ return Line(lineId, options, data);
+ }
+
+ @override
+ Future updateLine(Line line, LineOptions changes) async {
+ await _channel.invokeMethod('line#update', {
+ 'line': line.id,
+ 'options': changes.toJson(),
+ });
+ }
+
+ @override
+ Future removeLine(String lineId) async {
+ await _channel.invokeMethod('line#remove', {
+ 'line': lineId,
+ });
+ }
+
+ @override
+ Future addCircle(CircleOptions options, [Map data]) async {
+ final String circleId = await _channel.invokeMethod(
+ 'circle#add',
+ {
+ 'options': options.toJson(),
+ },
+ );
+ return Circle(circleId, options, data);
+ }
+
+ @override
+ Future updateCircle(Circle circle, CircleOptions changes) async {
+ await _channel.invokeMethod('circle#update', {
+ 'circle': circle.id,
+ 'options': changes.toJson(),
+ });
+ }
+
+ @override
+ Future getCircleLatLng(Circle circle) async {
+ Map mapLatLng =
+ await _channel.invokeMethod('circle#getGeometry', {
+ 'circle': circle.id,
+ });
+ return LatLng(mapLatLng['latitude'], mapLatLng['longitude']);
+ }
+
+ @override
+ Future removeCircle(String circleId) async {
+ await _channel.invokeMethod('circle#remove', {
+ 'circle': circleId,
+ });
+ }
+
+ @override
+ Future queryRenderedFeatures(
+ Point point, List layerIds, String filter) async {
+ try {
+ final Map reply = await _channel.invokeMethod(
+ 'map#queryRenderedFeatures',
+ {
+ 'x': point.x,
+ 'y': point.y,
+ 'layerIds': layerIds,
+ 'filter': filter,
+ },
+ );
+ return reply['features'];
+ } on PlatformException catch (e) {
+ return new Future.error(e);
+ }
+ }
+
+ @override
+ Future queryRenderedFeaturesInRect(
+ Rect rect, List layerIds, String filter) async {
+ try {
+ final Map reply = await _channel.invokeMethod(
+ 'map#queryRenderedFeatures',
+ {
+ 'left': rect.left,
+ 'top': rect.top,
+ 'right': rect.right,
+ 'bottom': rect.bottom,
+ 'layerIds': layerIds,
+ 'filter': filter,
+ },
+ );
+ return reply['features'];
+ } on PlatformException catch (e) {
+ return new Future.error(e);
+ }
+ }
+
+ @override
+ Future invalidateAmbientCache() async {
+ try {
+ await _channel.invokeMethod('map#invalidateAmbientCache');
+ return null;
+ } on PlatformException catch (e) {
+ return new Future.error(e);
+ }
+ }
+
+ @override
+ Future requestMyLocationLatLng() async {
+ try {
+ final Map reply = await _channel.invokeMethod(
+ 'locationComponent#getLastLocation', null);
+ double latitude = 0.0, longitude = 0.0;
+ if (reply.containsKey("latitude") && reply["latitude"] != null) {
+ latitude = double.parse(reply["latitude"].toString());
+ }
+ if (reply.containsKey("longitude") && reply["longitude"] != null) {
+ longitude = double.parse(reply["longitude"].toString());
+ }
+ return LatLng(latitude, longitude);
+ } on PlatformException catch (e) {
+ return new Future.error(e);
+ }
+ }
+
+ @override
+ Future getVisibleRegion() async {
+ try {
+ final Map reply =
+ await _channel.invokeMethod('map#getVisibleRegion', null);
+ LatLng southwest, northeast;
+ if (reply.containsKey("sw")) {
+ List coordinates = reply["sw"];
+ southwest = LatLng(coordinates[0], coordinates[1]);
+ }
+ if (reply.containsKey("ne")) {
+ List coordinates = reply["ne"];
+ northeast = LatLng(coordinates[0], coordinates[1]);
+ }
+ return LatLngBounds(southwest: southwest, northeast: northeast);
+ } on PlatformException catch (e) {
+ return new Future.error(e);
+ }
+ }
+
+ Future addImage(String name, Uint8List bytes,
+ [bool sdf = false]) async {
+ try {
+ return await _channel.invokeMethod('style#addImage', {
+ "name": name,
+ "bytes": bytes,
+ "length": bytes.length,
+ "sdf": sdf
+ });
+ } on PlatformException catch (e) {
+ return new Future.error(e);
+ }
+ }
+}
diff --git a/lib/src/symbol.dart b/mapbox_gl_platform_interface/lib/src/symbol.dart
similarity index 94%
rename from lib/src/symbol.dart
rename to mapbox_gl_platform_interface/lib/src/symbol.dart
index 2540582dd..4f4ea50d4 100644
--- a/lib/src/symbol.dart
+++ b/mapbox_gl_platform_interface/lib/src/symbol.dart
@@ -4,11 +4,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
class Symbol {
- @visibleForTesting
- Symbol(this._id, this._options, [this._data]);
+ Symbol(this._id, this.options, [this._data]);
/// A unique identifier for this symbol.
///
@@ -17,16 +16,15 @@ class Symbol {
String get id => _id;
- SymbolOptions _options;
-
final Map _data;
Map get data => _data;
+
/// The symbol configuration options most recently applied programmatically
/// via the map controller.
///
/// The returned value does not reflect any changes made to the symbol through
/// touch events. Add listeners to the owning map controller to track those.
- SymbolOptions get options => _options;
+ SymbolOptions options;
}
dynamic _offsetToJson(Offset offset) {
@@ -103,9 +101,7 @@ class SymbolOptions {
final int zIndex;
final bool draggable;
- static const SymbolOptions defaultOptions = SymbolOptions(
-
- );
+ static const SymbolOptions defaultOptions = SymbolOptions();
SymbolOptions copyWith(SymbolOptions changes) {
if (changes == null) {
@@ -142,7 +138,7 @@ class SymbolOptions {
);
}
- dynamic _toJson() {
+ dynamic toJson() {
final Map json = {};
void addIfPresent(String fieldName, dynamic value) {
@@ -175,10 +171,9 @@ class SymbolOptions {
addIfPresent('textHaloColor', textHaloColor);
addIfPresent('textHaloWidth', textHaloWidth);
addIfPresent('textHaloBlur', textHaloBlur);
- addIfPresent('geometry', geometry?._toJson());
+ addIfPresent('geometry', geometry?.toJson());
addIfPresent('zIndex', zIndex);
addIfPresent('draggable', draggable);
return json;
}
-
-}
\ No newline at end of file
+}
diff --git a/lib/src/ui.dart b/mapbox_gl_platform_interface/lib/src/ui.dart
similarity index 95%
rename from lib/src/ui.dart
rename to mapbox_gl_platform_interface/lib/src/ui.dart
index 3e9aaa207..460189533 100644
--- a/lib/src/ui.dart
+++ b/mapbox_gl_platform_interface/lib/src/ui.dart
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-part of mapbox_gl;
+part of mapbox_gl_platform_interface;
class MapboxStyles {
static const String MAPBOX_STREETS = "mapbox://styles/mapbox/streets-v11";
@@ -26,7 +26,8 @@ class MapboxStyles {
/// Satellite Streets: Global satellite and aerial imagery with unobtrusive labels. Using this
/// constant means your map style will always use the latest version and may change as we
/// improve the style.
- static const String SATELLITE_STREETS = "mapbox://styles/mapbox/satellite-streets-v11";
+ static const String SATELLITE_STREETS =
+ "mapbox://styles/mapbox/satellite-streets-v11";
/// Traffic Day: Color-coded roads based on live traffic congestion data. Traffic data is currently
/// available in
@@ -83,7 +84,7 @@ class CameraTargetBounds {
/// Unbounded camera target.
static const CameraTargetBounds unbounded = CameraTargetBounds(null);
- dynamic _toJson() => [bounds?._toList()];
+ dynamic toJson() => [bounds?.toList()];
@override
bool operator ==(dynamic other) {
@@ -120,7 +121,7 @@ class MinMaxZoomPreference {
static const MinMaxZoomPreference unbounded =
MinMaxZoomPreference(null, null);
- dynamic _toJson() => [minZoom, maxZoom];
+ dynamic toJson() =>