Icon is showing on wrong location in flutter map but showing the exact latlng where i am

Viewed 108

My latlng from this code is showing my exact location, but the icon is showing outside the country,I tried by printing my location and its showing the exact location but animating towards outside the country.

void getRideLiveLocationUpdates(){
        LatLng oldPos=LatLng(0,0);
        rideStreamSubscription= Geolocator.getPositionStream().listen((Position position) {
          currentPosition=position;
          myPostion=position;
          var rot = MapKitAssistant.getMarkerRotation(oldPos.latitude, oldPos.longitude, myPostion.latitude, myPostion.longitude);
    

      LatLng mPostion=LatLng(position.longitude,position.latitude);
      Marker animatingMarker=Marker(
        markerId: MarkerId("animating"),
        position: mPostion,
        icon: animatingMarkerIcon!,
        rotation:rot,
        infoWindow: InfoWindow(title: "Current Location"),


      );
      setState(() {
        CameraPosition cameraPosition=new CameraPosition(target: mPostion,zoom: 17);
        newRideGoogleMapController.animateCamera(CameraUpdate.newCameraPosition(cameraPosition));
        markersSet.removeWhere((marker) => marker.markerId.value=="animating");
        print("my longitude");
        print(mPostion.longitude);
        print("my latitude");
        print(mPostion.latitude);

        markersSet.add(animatingMarker);
      });
      oldPos=mPostion;

      updateRideDetail();
      String? rideRequestId=widget.rideDetails.ride_request_id;
      Map locMap={
        "latitude":currentPosition.latitude.toString(),
        "longitude":currentPosition.longitude.toString()


      };
      newRequestRef.child(rideRequestId!).child("driver_location").set(locMap);
    });
  }
0 Answers
Related