import 'package:flutter/widgets.dart'; import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_tile_provider.dart'; import 'package:flutter_map/flutter_map.dart'; import 'package:latlong2/latlong.dart'; import 'package:flutter/foundation.dart' show kIsWeb; class MyMAP extends StatelessWidget { final LatLng initCenter; final double initZoom; const MyMAP({super.key, this.initCenter = const LatLng(51.509364, -0.128928), this.initZoom = 15}); @override Widget build(BuildContext context) { TileProvider? tileProvider = null; if (kIsWeb) { tileProvider = CancellableNetworkTileProvider(); } return FlutterMap( options: MapOptions( initialCenter: initCenter, // Center the map over London initialZoom: initZoom, maxZoom:20, minZoom: 10, ), children: [ TileLayer( // Display map tiles from any source urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', tileProvider: tileProvider, // OSMF's Tile Server userAgentPackageName: 'com.example.app', maxNativeZoom: 19, // Scale tiles when the server doesn't support higher zoom levels // And many more recommended properties! ), // RichAttributionWidget( // Include a stylish prebuilt attribution widget that meets all requirments // attributions: [ // TextSourceAttribution( // 'OpenStreetMap contributors', // onTap: () => // launchUrl(Uri.parse( // 'https://openstreetmap.org/copyright')), // (external) // ), // // Also add images... // ], // ), ], ); } }