Skip to content

Commit

Permalink
add multiple maps support (#315)
Browse files Browse the repository at this point in the history
* add multiple maps support
* fix ScrollingMapPage example
* use local dependencies
  • Loading branch information
andrea689 authored Jun 9, 2020
1 parent d2a4b37 commit 4a80c87
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 90 deletions.
30 changes: 24 additions & 6 deletions example/lib/scrolling_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,20 @@ class ScrollingMapPage extends ExamplePage {

@override
Widget build(BuildContext context) {
return const ScrollingMapBody();
return ScrollingMapBody();
}
}

class ScrollingMapBody extends StatelessWidget {
const ScrollingMapBody();
class ScrollingMapBody extends StatefulWidget {
ScrollingMapBody();

@override
_ScrollingMapBodyState createState() => _ScrollingMapBodyState();
}

class _ScrollingMapBodyState extends State<ScrollingMapBody> {
MapboxMapController controllerOne;
MapboxMapController controllerTwo;

final LatLng center = const LatLng(32.080664, 34.9563837);

Expand All @@ -42,7 +50,8 @@ class ScrollingMapBody extends StatelessWidget {
width: 300.0,
height: 300.0,
child: MapboxMap(
onMapCreated: onMapCreated,
onMapCreated: onMapCreatedOne,
onStyleLoadedCallback: () => onStyleLoaded(controllerOne),
initialCameraPosition: CameraPosition(
target: center,
zoom: 11.0,
Expand Down Expand Up @@ -76,7 +85,8 @@ class ScrollingMapBody extends StatelessWidget {
width: 300.0,
height: 300.0,
child: MapboxMap(
onMapCreated: onMapCreated,
onMapCreated: onMapCreatedTwo,
onStyleLoadedCallback: () => onStyleLoaded(controllerTwo),
initialCameraPosition: CameraPosition(
target: center,
zoom: 11.0,
Expand All @@ -98,7 +108,15 @@ class ScrollingMapBody extends StatelessWidget {
);
}

void onMapCreated(MapboxMapController controller) {
void onMapCreatedOne(MapboxMapController controller) {
this.controllerOne = controller;
}

void onMapCreatedTwo(MapboxMapController controller) {
this.controllerTwo = controller;
}

void onStyleLoaded(MapboxMapController controller) {
controller.addSymbol(SymbolOptions(
geometry: LatLng(
center.latitude,
Expand Down
Loading

3 comments on commit 4a80c87

@kleeb
Copy link
Contributor

@kleeb kleeb commented on 4a80c87 Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this commit breaks the build

Error on line 10, column 11: Invalid description in the "mapbox_gl" pubspec on the "mapbox_gl_platform_interface" dependency: "mapbox_gl_platform_interface" is a relative path, but this isn't a local pubspec.

@m0nac0
Copy link
Collaborator

@m0nac0 m0nac0 commented on 4a80c87 Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kleeb Are you using the plugin through a git dependency in pubspec.yaml?
Also, there's #319 to change these dependencies.

@kleeb
Copy link
Contributor

@kleeb kleeb commented on 4a80c87 Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there are some reasons:

  1. I want to keep this repo up to date, pub.dev is heavily outdated:
    mapbox_gl: git: url: git://github.com/tobrun/flutter-mapbox-gl.git ref: master
  2. I am just finishing the offline support, where you will be able to define bounds and be able to use the predefined map boundaries completely offline. I will hit PR next week. Finishing edge cases testing.

Please sign in to comment.