8-8
This commit is contained in:
@@ -43,7 +43,8 @@ class MapController extends GetxController {
|
||||
|
||||
Future getPlaces() async {
|
||||
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: {});
|
||||
|
||||
@@ -107,7 +108,7 @@ class MapController extends GetxController {
|
||||
(_locationData.latitude != null && _locationData.longitude != null
|
||||
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
||||
: null)!;
|
||||
print(_locationData.accuracy);
|
||||
print('accuracy' + _locationData.accuracy.toString());
|
||||
print(_locationData.latitude);
|
||||
print(_locationData.time);
|
||||
print('//////////////////////////////////////');
|
||||
@@ -118,9 +119,9 @@ class MapController extends GetxController {
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
// controller.animateCamera(
|
||||
// CameraUpdate.newLatLng(mylocation),
|
||||
// );
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(mylocation),
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -163,14 +164,16 @@ class MapController extends GetxController {
|
||||
getDistanceFromText(data[0]['distance']['text']);
|
||||
|
||||
// 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));
|
||||
} else if (distanceOfDestnation > 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 8));
|
||||
} else if (distanceOfDestnation > 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 6));
|
||||
} else {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(mylocation, 11));
|
||||
}
|
||||
if (polylines.isNotEmpty) {
|
||||
clearpolyline();
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -14,9 +16,12 @@ final box = GetStorage();
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await GetStorage.init();
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
if (Platform.isAndroid || Platform.isIOS) {
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.currentPlatform,
|
||||
);
|
||||
}
|
||||
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,9 @@ import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'package:ride/constant/colors.dart';
|
||||
import 'package:ride/constant/style.dart';
|
||||
import 'package:ride/controller/home/map_page_controller.dart';
|
||||
|
||||
import '../../constant/style.dart';
|
||||
|
||||
class MapPage extends StatelessWidget {
|
||||
const MapPage({super.key});
|
||||
|
||||
@@ -64,16 +63,29 @@ class MapPage extends StatelessWidget {
|
||||
},
|
||||
polylines: {
|
||||
Polyline(
|
||||
zIndex: 2,
|
||||
consumeTapEvents: true,
|
||||
geodesic: true,
|
||||
endCap: Cap.buttCap,
|
||||
startCap: Cap.buttCap,
|
||||
visible: true,
|
||||
polylineId: const PolylineId('route'),
|
||||
points: controller.polylineCoordinates,
|
||||
color: AppColor.primaryColor,
|
||||
width: 3,
|
||||
)
|
||||
width: 5,
|
||||
),
|
||||
},
|
||||
mapType: MapType.normal,
|
||||
myLocationButtonEnabled: true,
|
||||
indoorViewEnabled: true,
|
||||
trafficEnabled: true,
|
||||
buildingsEnabled: true,
|
||||
mapToolbarEnabled: true,
|
||||
onCameraMove: (position) {
|
||||
controller.mylocation = position.target;
|
||||
},
|
||||
myLocationEnabled: true,
|
||||
// liteModeEnabled: true,
|
||||
),
|
||||
Positioned(
|
||||
top: 10,
|
||||
@@ -123,8 +135,46 @@ class MapPage extends StatelessWidget {
|
||||
},
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
res['name'].toString(),
|
||||
child: Column(
|
||||
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(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Container(
|
||||
height: 130,
|
||||
color: AppColor.secondaryColor,
|
||||
child:null)
|
||||
)
|
||||
// Positioned(
|
||||
// bottom: 0,
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// child: Container(
|
||||
// height: 130, color: AppColor.secondaryColor, child: null))
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user