added map cache

This commit is contained in:
Mohamed Nouffer
2023-03-17 11:54:12 +05:30
parent 044e5595c2
commit 05a812428a
15 changed files with 802 additions and 408 deletions

View File

@ -396,6 +396,8 @@ class DestinationController extends GetxController {
}
if(indexController.locations.isEmpty) return;
//check for location in bounds
for(GeoJsonFeature fs in indexController.locations[0].collection){

View File

@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_map/plugin_api.dart';
import 'package:flutter_map_location_marker/flutter_map_location_marker.dart';
import 'package:flutter_map_marker_popup/flutter_map_marker_popup.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geojson/geojson.dart';
import 'package:geolocator/geolocator.dart';
@ -15,6 +16,7 @@ import 'package:rogapp/pages/destination/destination_controller.dart';
import 'package:rogapp/pages/index/index_controller.dart';
import 'package:rogapp/services/destination_service.dart';
import 'package:rogapp/utils/text_util.dart';
import 'package:rogapp/widgets/base_layer_widget.dart';
import 'package:rogapp/widgets/bottom_sheet_new.dart';
import 'package:rogapp/widgets/bottom_sheet_widget.dart';
import 'package:rogapp/widgets/bread_crum_widget.dart';
@ -122,10 +124,9 @@ class DestinationMapPage extends StatelessWidget {
FlutterMap TravelMap() {
return FlutterMap(
mapController: indexController.rogMapController,
options: MapOptions(
onMapCreated: (c){
indexController.rogMapController = c;
indexController.rogMapController!.onReady.then((_) {
onMapReady: (){
indexController.is_rog_mapcontroller_loaded.value = true;
subscription = indexController.rogMapController!.mapEventStream.listen((MapEvent mapEvent) {
if (mapEvent is MapEventMoveStart) {
@ -133,7 +134,7 @@ class DestinationMapPage extends StatelessWidget {
if (mapEvent is MapEventMoveEnd) {
//destinationController.is_gps_selected.value = true;
//indexController.mapController!.move(c.center, c.zoom);
LatLngBounds bounds = c.bounds!;
LatLngBounds bounds = indexController.rogMapController!.bounds!;
indexController.currentBound.clear();
indexController.currentBound.add(bounds);
if(indexController.currentUser.length <= 0){
@ -141,7 +142,6 @@ class DestinationMapPage extends StatelessWidget {
}
}
});
});
} ,
bounds: indexController.currentBound.length > 0 ? indexController.currentBound[0]: LatLngBounds.fromPoints([LatLng(35.03999881162295, 136.40587119778962), LatLng(36.642756778706904, 137.95226720406063)]),
zoom: 1,
@ -149,16 +149,10 @@ class DestinationMapPage extends StatelessWidget {
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
),
children: [
TileLayerWidget(
options: TileLayerOptions(
urlTemplate: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
),
),
BaseLayer(),
Obx(() =>
indexController.routePointLenght > 0 ?
PolylineLayerWidget(
options: PolylineLayerOptions(
PolylineLayer(
polylines: [
Polyline(
points: getPoints()!,
@ -166,16 +160,14 @@ class DestinationMapPage extends StatelessWidget {
color: Colors.indigo
),
],
),
)
:
Container(),
),
LocationMarkerLayerWidget(),
MarkerLayerWidget(
options: MarkerLayerOptions(
markers: getMarkers()!
),
CurrentLocationLayer(),
MarkerLayer(
markers: getMarkers()!
),
],

View File

@ -46,8 +46,8 @@ class IndexController extends GetxController {
var is_custom_area_selected = false.obs;
MapController? mapController;
MapController? rogMapController;
MapController mapController = MapController();
MapController rogMapController = MapController();
var mode = 0.obs;

View File

@ -39,7 +39,7 @@ class _LandingPageState extends State<LandingPage> {
Container(
height: MediaQuery.of(context).size.height/3,
decoration: BoxDecoration(
image:DecorationImage(image: AssetImage('assets/gradient_japanese_temple.jpg'))
image:DecorationImage(image: AssetImage('assets/images/gradient_japanese_temple.jpg'))
),
),
SizedBox(height: 20.0,),