osm_flutter icon indicating copy to clipboard operation
osm_flutter copied to clipboard

Possible to implement drop pin feature ?

Open jesussmile opened this issue 3 years ago • 11 comments

Currently, to pick a location I am using your showSimplePickerLocation widget, However, is it possible to use it from the OSMflutter widget itself as I have to open two different screens? sth like this? https://pub.dev/packages/map_pin_picker

jesussmile avatar Aug 06 '21 10:08 jesussmile

yeah you can open two different screen and each screen contain its own OSMFlutter

liodali avatar Aug 06 '21 12:08 liodali

I meant in one screen. In osmflutter only. I dont want to open two screen. I want to use the picker in osmflutter widget as it takes time to load the map everytime I use mappicker.. Is that possible or if u could tell how I could do it. I will try it out.

jesussmile avatar Aug 06 '21 13:08 jesussmile

i think to implemented you need some other feature should be add it to plugin like getGeoPointCenter() direclty

liodali avatar Aug 06 '21 13:08 liodali

i will make more reseach about what mappicker propose to see how i can help you to acheive that

liodali avatar Aug 06 '21 13:08 liodali

i think you can use pickerMapController and change isPicker OSMFlutter to true and the icon make it invisible or empty widget like SizedBox.shrink() and use method of pickerMapController to getCenterPosition

liodali avatar Aug 06 '21 13:08 liodali

ezgif com-gif-maker This, is what I want to achieve , Now in my OSMFlutter widget, I can get the MapPicker,

 child: MapPicker(
                    iconWidget: Icon(
                      Icons.location_pin,
                      size: 30,
                      color: Colors.red,
                    ),
                    //add map picker controller
                    mapPickerController: mapPickerController,
                    child: (OSMFlutter(
                      key: _mapKey,
                      controller: osmController,

                      staticPoints: [
                        StaticPositionGeoPoint(
                          driverKey,
                          MarkerIcon(
                            //icon: null,
                            icon: Icon(Icons.star),
                          ),
                          [GeoPoint(latitude: driverLat, longitude: driverLon)],
                        ),
                      ],
                      //currentLocation: false,
                      road: Road(
                        startIcon: MarkerIcon(
                          icon: Icon(
                            Icons.pin_drop,
                            size: 64,
                            color: Colors.green,
                          ),
                        ),
                        roadColor: Colors.yellowAccent,
                      ),
                      markerOption: MarkerOption(
                          defaultMarker: MarkerIcon(
                        icon: Icon(null
                            //Icons.star_half_rounded,
                            //color: Colors.blue,
                            //size: 56,
                            ),
                      )),
                    )),
                  ),

but to get the MapPicker working I need these three functions


onCameraMoveStarted: () {
                  // notify map is moving
                  mapPickerController.mapMoving();
                },
                onCameraMove: (cameraPosition) {
                  this.cameraPosition = cameraPosition;
                },
                onCameraIdle: () async {
                  // notify map stopped moving
                  mapPickerController.mapFinishedMoving();
                  //get address name from camera position
                  List<Address> addresses = await Geocoder.local
                      .findAddressesFromCoordinates(Coordinates(
                      cameraPosition.target.latitude,
                      cameraPosition.target.longitude));
                  // update the ui with the address
                  textController.text='${addresses.first?.addressLine ?? ''}';
                },

I know you are busy, if you can give me few suggestion then I will work on it.

jesussmile avatar Aug 06 '21 14:08 jesussmile

yeah i should add onCameraMoveStarted,onCameraIdle but implementing onCameraIdle will be tricky on the android side

liodali avatar Aug 06 '21 14:08 liodali

i can add getCenterPosition and you can compare between current value and previous to start or finishMoving

liodali avatar Aug 06 '21 14:08 liodali

Okay! That would be great!

jesussmile avatar Aug 06 '21 14:08 jesussmile

try to put isPicker in OSMFlutter to true and use PickerMapController as Controller and use this method getCurrentPositionAdvancedPositionPicker to get centerGeoPoint for comparaison between previous and current geoPoint and for icon use any icon with transparent color or withOpacity(0) to make it invisible and size equal to 0

liodali avatar Aug 06 '21 14:08 liodali

Oh! That should work I think. I will give it a try. Thank you.

jesussmile avatar Aug 06 '21 14:08 jesussmile