Open Alisofin opened 2 years ago
you have any log error and if you want to get geopoint when you click on the map use this
controller.listenerMapSingleTapping.addListener(() {
if (controller.listenerMapSingleTapping.value != null) {
/// put you logic here
}
});
the onGeoPointClicked
callback for marker click
thanks for your quick answer. In fact, I add markers controller.addMarker(GeoPoint()..) and I detect click on them with onGeoPointClicked. Is it the right thing to do ?
yeah yeah Just for note that in ios side get click marker little different from android I will check it and i will try to fix that
Behavior confirmed on iOS. When the map is built for the first time the onGeoPointClicked
is never called. I need to change route and back again or hot-reload the app to make it work. Is there any update on this?
Thank you!
provide me some example of your widget to see and are you using real iphone or emulator
import 'package:flutter/material.dart';
import 'package:flutter_osm_plugin/flutter_osm_plugin.dart';
// flutter_osm_plugin: 0.37.2+1
void main() { runApp(const MaterialApp(home: CustomMap())); }
class CustomMap extends StatefulWidget { const CustomMap({Key? key}) : super(key: key);
@override CustomMapState createState() => CustomMapState(); }
class CustomMapState extends State
@override void initState() { super.initState(); controller = MapController( initMapWithUserPosition: false, initPosition: GeoPoint( latitude: 41.889032, longitude: 12.496164, ), )..addObserver(this); }
@override void dispose() { super.dispose(); }
@override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, appBar: AppBar(), body: OrientationBuilder( builder: (ctx, orientation) { return Stack( children: [ OSMFlutter( controller: controller, initZoom: 10, trackMyPosition: false, mapIsLoading: SizedBox.expand( child: Container( color: Colors.black, child: const Center( child: CircularProgressIndicator( color: Colors.white, ), ), ), ), showContributorBadgeForOSM: false, showDefaultInfoWindow: false, markerOption: MarkerOption( defaultMarker: const MarkerIcon( icon: Icon( Icons.location_on, color: Colors.red, size: 100, ), ), ), onGeoPointClicked: (geoPoint) { print("GEOPOINT CLICKED ONLY AFTER HOT-RESTART"); }, ), ], ); }, ), ); }
@override
Future
Any update on this?
i tested with real device (iphone) and I didn't face that problem wierd try to use custon icon for marker i will try to make more investigation on icon clicks
I tried with Flutter 3.0.5 and your release 0.39.0 and it's working correctly.
Hello, Sometimes, just after the map has been displayed, the onGeoPointClicked method doesn't work, the map doesn't react to any click. You need to leave the page and re-enter to make it work. I haven't found any specific pattern to reproduce it but it happens on 20% of cases, both on simulator and real iOS device. Please help.