paznogard
paznogard

Reputation: 42

How can i move map under marker like UBER in FLUTTER?

I want to move a marker like Uber, I found an example in Android but I need to do in Flutter, Can somebody help me?

Upvotes: 0

Views: 3294

Answers (2)

Praveen Kumar
Praveen Kumar

Reputation: 221

If you are using google_maps_flutter package, onCameraMove will always give you the lat, lng of the center of the map. So you can have a Stack and place a marker like an image at the center on top of the map.

               Stack(children: <Widget>[
                GoogleMap(
                  initialCameraPosition: _initialCamera,
                  onMapCreated: _mapCreated,
                  onCameraMove: (position) {
                    newLocation = position.target;
                  },
                  onCameraIdle: () async {
                    // you can use the captured location here. when the user stops moving the map.
                  },
                ),
               //This is your marker
                Align(
                  alignment: Alignment.center,
                  child: Icon(Icons.place),
                ),
              ])

Upvotes: 3

Jim
Jim

Reputation: 7601

  1. Drop marker on current location
  2. Remove marker onCameraMove and place pin image on the middle of map in Stack
  3. Remove pin image and drop new marker on current location by CameraPosition onCameraIdle

Upvotes: 0

Related Questions