Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0.0: Simplify External & Internal Layer Handling #1333

Merged
merged 32 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad72887
bump dart 2.17; remove layeroptions
mootw Aug 2, 2022
ecaafed
basic migration of built in layers. Optimizations can be done
mootw Aug 3, 2022
4fc999c
remove plugins because they are useless now
mootw Aug 3, 2022
d2455b9
migrate example app to new plugin
mootw Aug 3, 2022
26db69e
migrate tests
mootw Aug 3, 2022
fcd403b
unnecessary empty check
mootw Aug 3, 2022
98a40aa
fix accidental commit
mootw Aug 3, 2022
5c23861
new super super
mootw Aug 3, 2022
0513912
instantiate mapcontrollerimpl at construction; mod circle layer; add …
mootw Aug 3, 2022
10b4c1a
remove options from zoom buttons example
mootw Aug 3, 2022
5d02dee
assume new major version
mootw Aug 3, 2022
f7d9674
mod api's. Working on MarkerLayer; caching behavior needs to be tested
mootw Aug 3, 2022
244f0fa
remove marker layer cache
mootw Aug 3, 2022
f4b6163
migrate circle layer
mootw Aug 3, 2022
e942cfa
remove on ready and dispose streamGroups
mootw Aug 3, 2022
1826e5d
remove onmapcreated
mootw Aug 3, 2022
aed86a3
rough new state management implementation
mootw Aug 4, 2022
4bf3d19
improve degrees and pixel origin
mootw Aug 4, 2022
9ca935f
rename variables and functions; _lastCenter is now non-nullable
mootw Aug 4, 2022
22a602b
improve state management and clean up variable names
mootw Aug 4, 2022
10fe1c6
fix lint
mootw Aug 4, 2022
c23e4ba
Update lib/src/layer/overlay_image_layer.dart
mootw Aug 4, 2022
d270a86
fix state handling issues, implement event stream in controller
mootw Aug 7, 2022
b166628
migrate tilelayer to match api
mootw Aug 10, 2022
c6f31ea
fix 1308 and remove allowPanning (broken anways)
mootw Aug 10, 2022
321d0da
move calculations outside of layoutbuilder
mootw Aug 11, 2022
b680cce
fix regression with layout
mootw Aug 11, 2022
8133cef
fix hero error in example app
mootw Aug 11, 2022
7604b41
add onMapReady to mapOptions
mootw Aug 11, 2022
c3e5354
convert onMapReady to postFrameCallback remove map controller from op…
mootw Aug 11, 2022
f529563
fix state issue. remote unused _rotationRad
mootw Aug 16, 2022
0f9690d
remove deprecated provider
mootw Aug 16, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:flutter_map_example/pages/network_tile_provider.dart';
import 'package:flutter_map_example/pages/offline_map.dart';
import 'package:flutter_map_example/pages/on_tap.dart';
import 'package:flutter_map_example/pages/overlay_image.dart';
import 'package:flutter_map_example/pages/plugin_api.dart';
import 'package:flutter_map_example/pages/plugin_scalebar.dart';
import 'package:flutter_map_example/pages/plugin_zoombuttons.dart';
import 'package:flutter_map_example/pages/point_to_latlng.dart';
Expand Down Expand Up @@ -61,7 +60,6 @@ class MyApp extends StatelessWidget {
AnimatedMapControllerPage.route: (context) =>
const AnimatedMapControllerPage(),
MarkerAnchorPage.route: (context) => const MarkerAnchorPage(),
PluginPage.route: (context) => const PluginPage(),
PluginScaleBar.route: (context) => const PluginScaleBar(),
PluginZoomButtons.route: (context) => const PluginZoomButtons(),
OfflineMapPage.route: (context) => const OfflineMapPage(),
Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/animated_map_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ class AnimatedMapControllerPageState extends State<AnimatedMapControllerPage>
zoom: 5,
maxZoom: 10,
minZoom: 3),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
MarkerLayerOptions(markers: markers)
MarkerLayer(markers: markers),
],
),
),
Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ class CirclePage extends StatelessWidget {
center: LatLng(51.5, -0.09),
zoom: 11,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
CircleLayerOptions(circles: circleMarkers)
CircleLayer(circles: circleMarkers),
],
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/pages/custom_crs/custom_crs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ class _CustomCrsPageState extends State<CustomCrsPage> {
point = proj4.Point(x: p.latitude, y: p.longitude);
}),
),
layers: [
TileLayerOptions(
children: [
TileLayer(
opacity: 1,
backgroundColor: Colors.transparent,
wmsOptions: WMSTileLayerOptions(
Expand Down
10 changes: 4 additions & 6 deletions example/lib/pages/epsg3413_crs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
zoom: 3,
maxZoom: maxZoom,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
opacity: 1,
backgroundColor: Colors.transparent,
wmsOptions: WMSTileLayerOptions(
Expand All @@ -146,7 +146,7 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
layers: ['gebco_north_polar_view'],
),
),
OverlayImageLayerOptions(
OverlayImageLayer(
overlayImages: [
OverlayImage(
bounds: LatLngBounds(
Expand All @@ -159,9 +159,7 @@ class _EPSG3413PageState extends State<EPSG3413Page> {
)
],
),
CircleLayerOptions(
circles: circles,
),
CircleLayer(circles: circles),
],
),
),
Expand Down
4 changes: 2 additions & 2 deletions example/lib/pages/epsg4326_crs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class EPSG4326Page extends StatelessWidget {
center: LatLng(0, 0),
zoom: 0,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
wmsOptions: WMSTileLayerOptions(
crs: const Epsg4326(),
baseUrl: 'https://ows.mundialis.de/services/service?',
Expand Down
4 changes: 2 additions & 2 deletions example/lib/pages/esri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class EsriPage extends StatelessWidget {
center: LatLng(45.5231, -122.6765),
zoom: 13,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
Expand Down
18 changes: 9 additions & 9 deletions example/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,21 @@ class HomePage extends StatelessWidget {
center: LatLng(51.5, -0.09),
zoom: 5,
),
layers: [
TileLayerOptions(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
MarkerLayerOptions(markers: markers)
],
nonRotatedChildren: [
AttributionWidget.defaultWidget(
source: 'OpenStreetMap contributors',
onSourceTapped: () {},
),
],
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
MarkerLayer(markers: markers),
],
),
),
],
Expand Down
42 changes: 11 additions & 31 deletions example/lib/pages/interactive_test_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,26 @@ class InteractiveTestPage extends StatefulWidget {
}

class _InteractiveTestPageState extends State<InteractiveTestPage> {
late final MapController mapController;

// Enable pinchZoom and doubleTapZoomBy by default
int flags = InteractiveFlag.pinchZoom | InteractiveFlag.doubleTapZoom;

late final StreamSubscription<MapEvent> subscription;
MapEvent? _latestEvent;

@override
void initState() {
super.initState();
mapController = MapController();

subscription = mapController.mapEventStream.listen(onMapEvent);
}

@override
void dispose() {
subscription.cancel();

super.dispose();
}

void onMapEvent(MapEvent mapEvent) {
if (mapEvent is! MapEventMove && mapEvent is! MapEventRotate) {
// do not flood console with move and rotate events
debugPrint(mapEvent.toString());
}

setState(() {
_latestEvent = mapEvent;
});
}

void updateFlags(int flag) {
Expand Down Expand Up @@ -148,35 +141,22 @@ class _InteractiveTestPageState extends State<InteractiveTestPage> {
Padding(
padding: const EdgeInsets.only(top: 8, bottom: 8),
child: Center(
child: StreamBuilder<MapEvent>(
stream: mapController.mapEventStream,
builder:
(BuildContext context, AsyncSnapshot<MapEvent> snapshot) {
if (!snapshot.hasData) {
return const Text(
'Current event: none\nSource: none',
textAlign: TextAlign.center,
);
}

return Text(
'Current event: ${snapshot.data.runtimeType}\nSource: ${snapshot.data!.source}',
child: Text(
'Current event: ${_latestEvent?.runtimeType ?? "none"}\nSource: ${_latestEvent?.source ?? "none"}',
textAlign: TextAlign.center,
);
},
),
),
),
),
Flexible(
child: FlutterMap(
mapController: mapController,
options: MapOptions(
onMapEvent: onMapEvent,
center: LatLng(51.5, -0.09),
zoom: 11,
interactiveFlags: flags,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
Expand Down
30 changes: 11 additions & 19 deletions example/lib/pages/latlng_to_screen_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,14 @@ class LatLngScreenPointTestPage extends StatefulWidget {
}

class _LatLngScreenPointTestPageState extends State<LatLngScreenPointTestPage> {
late final MapController mapController;
late final StreamSubscription<MapEvent> subscription;
late final MapController _mapController;

CustomPoint textPos = const CustomPoint(10.0, 10.0);
CustomPoint _textPos = const CustomPoint(10.0, 10.0);

@override
void initState() {
super.initState();
mapController = MapController();
subscription = mapController.mapEventStream.listen(onMapEvent);
}

@override
void dispose() {
subscription.cancel();

super.dispose();
_mapController = MapController();
}

void onMapEvent(MapEvent mapEvent) {
Expand All @@ -53,19 +44,20 @@ class _LatLngScreenPointTestPageState extends State<LatLngScreenPointTestPage> {
Padding(
padding: const EdgeInsets.all(8),
child: FlutterMap(
mapController: mapController,
mapController: _mapController,
options: MapOptions(
onMapEvent: onMapEvent,
onTap: (tapPos, latLng) {
final pt1 = mapController.latLngToScreenPoint(latLng);
textPos = CustomPoint(pt1!.x, pt1.y);
final pt1 = _mapController.latLngToScreenPoint(latLng);
_textPos = CustomPoint(pt1!.x, pt1.y);
setState(() {});
},
center: LatLng(51.5, -0.09),
zoom: 11,
rotation: 0,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
Expand All @@ -75,8 +67,8 @@ class _LatLngScreenPointTestPageState extends State<LatLngScreenPointTestPage> {
),
),
Positioned(
left: textPos.x.toDouble(),
top: textPos.y.toDouble(),
left: _textPos.x.toDouble(),
top: _textPos.y.toDouble(),
width: 20,
height: 20,
child: const FlutterLogo())
Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/live_location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ class _LiveLocationPageState extends State<LiveLocationPage> {
zoom: 5,
interactiveFlags: interActiveFlags,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
MarkerLayerOptions(markers: markers)
MarkerLayer(markers: markers),
],
),
),
Expand Down
6 changes: 3 additions & 3 deletions example/lib/pages/many_markers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ class _ManyMarkersPageState extends State<ManyMarkersPage> {
zoom: 5,
interactiveFlags: InteractiveFlag.all - InteractiveFlag.rotate,
),
layers: [
TileLayerOptions(
children: [
TileLayer(
urlTemplate:
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
userAgentPackageName: 'dev.fleaflet.flutter_map.example',
),
MarkerLayerOptions(
MarkerLayer(
markers: allMarkers.sublist(
0, min(allMarkers.length, _sliderVal))),
],
Expand Down
Loading