8-8
This commit is contained in:
@@ -43,7 +43,8 @@ class MapController extends GetxController {
|
|||||||
|
|
||||||
Future getPlaces() async {
|
Future getPlaces() async {
|
||||||
var url =
|
var url =
|
||||||
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=32.111946,${mylocation.longitude}&radius=10000&type=restaurant&language=ar&key=${AppCredintials.mapAPIKEY}';
|
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AppCredintials.mapAPIKEY}';
|
||||||
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeController.text}&location=32.111946,${mylocation.longitude}&radius=10000&language=ar&key=${AppCredintials.mapAPIKEY}';
|
||||||
|
|
||||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ class MapController extends GetxController {
|
|||||||
(_locationData.latitude != null && _locationData.longitude != null
|
(_locationData.latitude != null && _locationData.longitude != null
|
||||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||||
: null)!;
|
: null)!;
|
||||||
print(_locationData.accuracy);
|
print('accuracy' + _locationData.accuracy.toString());
|
||||||
print(_locationData.latitude);
|
print(_locationData.latitude);
|
||||||
print(_locationData.time);
|
print(_locationData.time);
|
||||||
print('//////////////////////////////////////');
|
print('//////////////////////////////////////');
|
||||||
@@ -118,9 +119,9 @@ class MapController extends GetxController {
|
|||||||
void onMapCreated(GoogleMapController controller) {
|
void onMapCreated(GoogleMapController controller) {
|
||||||
mapController = controller;
|
mapController = controller;
|
||||||
controller.getVisibleRegion();
|
controller.getVisibleRegion();
|
||||||
// controller.animateCamera(
|
controller.animateCamera(
|
||||||
// CameraUpdate.newLatLng(mylocation),
|
CameraUpdate.newLatLng(mylocation),
|
||||||
// );
|
);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,14 +164,16 @@ class MapController extends GetxController {
|
|||||||
getDistanceFromText(data[0]['distance']['text']);
|
getDistanceFromText(data[0]['distance']['text']);
|
||||||
|
|
||||||
// Animate the camera to the adjusted bounds
|
// Animate the camera to the adjusted bounds
|
||||||
if (distanceOfDestnation > 16 && distanceOfDestnation < 30) {
|
if (distanceOfDestnation <= 10) {
|
||||||
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 14));
|
||||||
|
} else if (distanceOfDestnation > 10 && distanceOfDestnation < 16) {
|
||||||
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 12));
|
||||||
|
} else if (distanceOfDestnation > 16 && distanceOfDestnation < 30) {
|
||||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10));
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 10));
|
||||||
} else if (distanceOfDestnation > 30 && distanceOfDestnation < 100) {
|
} else if (distanceOfDestnation > 30 && distanceOfDestnation < 100) {
|
||||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 8));
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 8));
|
||||||
} else if (distanceOfDestnation > 100) {
|
} else if (distanceOfDestnation > 100) {
|
||||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 6));
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 6));
|
||||||
} else {
|
|
||||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11));
|
|
||||||
}
|
}
|
||||||
if (polylines.isNotEmpty) {
|
if (polylines.isNotEmpty) {
|
||||||
clearpolyline();
|
clearpolyline();
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -14,9 +16,12 @@ final box = GetStorage();
|
|||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await GetStorage.init();
|
await GetStorage.init();
|
||||||
await Firebase.initializeApp(
|
if (Platform.isAndroid || Platform.isIOS) {
|
||||||
options: DefaultFirebaseOptions.currentPlatform,
|
await Firebase.initializeApp(
|
||||||
);
|
options: DefaultFirebaseOptions.currentPlatform,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||||
import 'package:ride/constant/colors.dart';
|
import 'package:ride/constant/colors.dart';
|
||||||
|
import 'package:ride/constant/style.dart';
|
||||||
import 'package:ride/controller/home/map_page_controller.dart';
|
import 'package:ride/controller/home/map_page_controller.dart';
|
||||||
|
|
||||||
import '../../constant/style.dart';
|
|
||||||
|
|
||||||
class MapPage extends StatelessWidget {
|
class MapPage extends StatelessWidget {
|
||||||
const MapPage({super.key});
|
const MapPage({super.key});
|
||||||
|
|
||||||
@@ -64,16 +63,29 @@ class MapPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
polylines: {
|
polylines: {
|
||||||
Polyline(
|
Polyline(
|
||||||
|
zIndex: 2,
|
||||||
|
consumeTapEvents: true,
|
||||||
|
geodesic: true,
|
||||||
|
endCap: Cap.buttCap,
|
||||||
|
startCap: Cap.buttCap,
|
||||||
|
visible: true,
|
||||||
polylineId: const PolylineId('route'),
|
polylineId: const PolylineId('route'),
|
||||||
points: controller.polylineCoordinates,
|
points: controller.polylineCoordinates,
|
||||||
color: AppColor.primaryColor,
|
color: AppColor.primaryColor,
|
||||||
width: 3,
|
width: 5,
|
||||||
)
|
),
|
||||||
},
|
},
|
||||||
mapType: MapType.normal,
|
mapType: MapType.normal,
|
||||||
myLocationButtonEnabled: true,
|
myLocationButtonEnabled: true,
|
||||||
indoorViewEnabled: true,
|
indoorViewEnabled: true,
|
||||||
trafficEnabled: true,
|
trafficEnabled: true,
|
||||||
|
buildingsEnabled: true,
|
||||||
|
mapToolbarEnabled: true,
|
||||||
|
onCameraMove: (position) {
|
||||||
|
controller.mylocation = position.target;
|
||||||
|
},
|
||||||
|
myLocationEnabled: true,
|
||||||
|
// liteModeEnabled: true,
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
top: 10,
|
top: 10,
|
||||||
@@ -123,8 +135,46 @@ class MapPage extends StatelessWidget {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Column(
|
||||||
res['name'].toString(),
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment:
|
||||||
|
MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Image.network(
|
||||||
|
res['icon'],
|
||||||
|
width: 30,
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
res['name'].toString(),
|
||||||
|
style: AppStyle.title,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
res['vicinity'].toString(),
|
||||||
|
style: AppStyle.subtitle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
'rate',
|
||||||
|
style: AppStyle.subtitle,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
res['rating'].toString(),
|
||||||
|
style: AppStyle.subtitle,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(
|
||||||
|
thickness: 1,
|
||||||
|
)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -133,15 +183,12 @@ class MapPage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Positioned(
|
// Positioned(
|
||||||
bottom: 0,
|
// bottom: 0,
|
||||||
left: 0,
|
// left: 0,
|
||||||
right: 0,
|
// right: 0,
|
||||||
child: Container(
|
// child: Container(
|
||||||
height: 130,
|
// height: 130, color: AppColor.secondaryColor, child: null))
|
||||||
color: AppColor.secondaryColor,
|
|
||||||
child:null)
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user