title: Flutter: How do I update markers' position in google map using Getx Obx?
body: <p>I have following <code>view</code></p>
  <pre><code>import 'dart:async';
  import 'package:get/get.dart';
  import 'package:flutter/material.dart';
  import 'package:google_maps_flutter/google_maps_flutter.dart';
  import '../../Controllers/mapview_controller.dart';
  
  class MapViewerPage extends StatelessWidget {
    MapViewerPage({Key? key}) : super(key: key);
  
    final MapViewController mapcontroller = MapViewController();
    final Completer&lt;GoogleMapController&gt; _controller = Completer();
    final CameraPosition _initialCameraPosition = const CameraPosition(
      target: LatLng(28.527582, 77.0688971),
      zoom: 16,
    );
  
    final BitmapDescriptor defaultIcon =
        BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueRed);
  
    final List&lt;Marker&gt; allMarkers = [];
  
    @override
    Widget build(BuildContext context) {
      return GetBuilder&lt;MapViewController&gt;(
          init: mapcontroller,
          builder: (controller) {
             return SizedBox(
                width: double.infinity,
                height: double.infinity,
                child: Obx(() =&gt; GoogleMap(
              myLocationButtonEnabled: true,
              markers:Set&lt;Marker&gt;.of(allMarkers),
              mapType: MapType.normal,
              initialCameraPosition: _initialCameraPosition,
              onMapCreated: (GoogleMapController gmcontroller) {
                _controller.complete(gmcontroller);
                gmcontroller.setMapStyle(controller.loadMapStyle());
              },
            )),
              ),
          });
    }
  
    getMarkers() {
      //get markers from controller
      var realdata = mapcontroller.realtimeList;
  
      realdata.asMap().forEach((key, value) {
        var _marker = Marker(
            consumeTapEvents: true,
            markerId: MarkerId(key.toString()),
            position: LatLng(
                double.parse(value.latitude), double.parse(value.longitude)),
            onTap: () {
              //do something here
            });
  
        allMarkers.add(_marker);
      });
    }
  }
  </code></pre>
  <p>And my controller looks like this.</p>
  <pre><code>import 'package:flutter/services.dart';
  import 'package:get/get.dart';
  import '../../Models/model_realtime.dart';
  import '../../Providers/common_api_provider.dart';
  
  class MapViewController extends GetxController {
    var isLoading = false.obs;
    var realtimeList = &lt;ModelRealtime&gt;[].obs;
  
    @override
    void onInit() {
      fetchRealtimeData();
      super.onInit();
    }
  
    void fetchRealtimeData() async {
      try {
        isLoading(true);
        var realtime = await CommonApiProvider.realTimeData();
        if (realtime != null) {
          realtimeList.value = realtime;
        }
      } catch (e) {
        isLoading(false);
        // ignore: avoid_print
        print(e);
        rethrow;
      } finally {
        isLoading(false);
      }
    }
  
    loadMapStyle() async {
      String style = await rootBundle.loadString(&quot;assets/map_style.json&quot;);
      return style;
    }
  }
  </code></pre>
  <p>These codes work pretty well, but it seems to reload/refresh Googlemap everytime new data arrives. How do I update markers' position only everytime the new latitude, longitude updated in the database without reloading/refreshing  Googlemap?</p>
  <p>Thanks</p>