اذهب إلى المحتوى
  • 0

إضافة علامة مخصصة على الخريطة و تفعيل علامة GPS في Flutter

Mohammed Abu Yousef

السؤال

كيفية إضافة هاتين العلامتين كما يظهر في الصورة المرفقة:

1- العلامة الأولى: عند الضغط عليها، يتم التحقق من تشغيل ال GPS ومن ثم الانتقال إلى الموقع الحالي.

2- العلامة الثانية: يستطيع المستخدم من خلالها إضافة marker خاص به في موقع يقوم هو بتحديده، ومن ثم حفظه في ال API.

map_google.jpg

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 1

يمكنك استخدام حزمة location من هنا لتستطيع تشغيل و إيقاف GPS و التحقق ايضا من أنه مفعل أو لا .

Future checkGps() async {
    if (!await location.serviceEnabled()) {
      location.requestService();
    }
  }
import 'package:location/location.dart' as loc;

loc.Location location = loc.Location();//explicit reference to the Location class
Future _checkGps() async {
if (!await location.serviceEnabled()) {
  location.requestService();
 }
}

بخصوص العلامة الثانية, يمكنك استخدام حزمة flutter_google_maps  من هنا و هذا مثال لكيفية وضع أيقونة خاصة على الخريطة 

class _HomeState extends State<Home> with WidgetsBindingObserver {

@override

void initState() {

  super.initState();

  markers = Set.from([]);
  
}

  GoogleMapController mapController;

  BitmapDescriptor customIcon1;
  
  Set<Marker> markers;

createMarker(context) {

  if (customIcon1 == null) {

    ImageConfiguration configuration = createLocalImageConfiguration(context);

    BitmapDescriptor.fromAssetImage(configuration, 'assets/images/fire.png')

        .then((icon) {

      setState(() {

        customIcon1 = icon;

      });

    });

  }
}

 

رابط هذا التعليق
شارك على الشبكات الإجتماعية

  • 0
بتاريخ 21 ساعات قال بلال زيادة:

يمكنك استخدام حزمة location من هنا لتستطيع تشغيل و إيقاف GPS و التحقق ايضا من أنه مفعل أو لا .


Future checkGps() async {
    if (!await location.serviceEnabled()) {
      location.requestService();
    }
  }

import 'package:location/location.dart' as loc;

loc.Location location = loc.Location();//explicit reference to the Location class
Future _checkGps() async {
if (!await location.serviceEnabled()) {
  location.requestService();
 }
}

بخصوص العلامة الثانية, يمكنك استخدام حزمة flutter_google_maps  من هنا و هذا مثال لكيفية وضع أيقونة خاصة على الخريطة 


class _HomeState extends State<Home> with WidgetsBindingObserver {

@override

void initState() {

  super.initState();

  markers = Set.from([]);
  
}

  GoogleMapController mapController;

  BitmapDescriptor customIcon1;
  
  Set<Marker> markers;

createMarker(context) {

  if (customIcon1 == null) {

    ImageConfiguration configuration = createLocalImageConfiguration(context);

    BitmapDescriptor.fromAssetImage(configuration, 'assets/images/fire.png')

        .then((icon) {

      setState(() {

        customIcon1 = icon;

      });

    });

  }
}

 

شكرا، لكن هل تملك Widget فيها كل هذه التفاصيل ( الخريطة وعليها كل هذه التفاصيل )، حتى لا أضطر لكتابتها من جديد

رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...