MapView marker show previous on iOS

  

With Firemonkey 10.4.2.
I had a problem when I click on marker.
If I do that

Click on Marker A
Click on Marker B
Click on Map
Click on Marker A => I see info of Marker B, the MapMarker of MapViewMarkerClick is bad

I find a problem on FMX.Maps.iOS the last Marker is keep in memory and never set to nil, that’s why I always have the same. When you click on a marker, it’s look like you go to MapClick and then MapMarkerClick. That’s not really clear.
When the map is shown with all marker. If click on Marker A, I first go to MapClick, I need to click a second time on the Marker to see it. Then I can naviguate to each marker, but if I click on map. The next time I click on marker I need to do it 2x.
All is good on Android, I think it’s a problem in FMX.Maps.iOS again.
Any idea ?
Here is the original code with my edit :
procedure TMapKitMapView.MapEvent(const Event: TMapEvent);
// added
var
SelectedMarker: TMapMarker;
// end added
begin
// added
SelectedMarker := FSelectedMarker;
// end added

case Event.Kind of
TMapEventKind.CameraChanged:
begin
SyncCameraPosition;
FHostControl.DoCameraChanged;
end;
TMapEventKind.MarkerClick:
begin
// Marker has been selected
FSelectedMarker := Event.Marker;
FHostControl.DoMarkerClick(Event.Marker);
end;
TMapEventKind.MarkerDeselect:
FSelectedMarker := nil;
TMapEventKind.MarkerDragStart:
FHostControl.DoMarkerDragStart(Event.Marker);
TMapEventKind.MarkerDrag:
FHostControl.DoMarkerDrag(Event.Marker);
TMapEventKind.MarkerDragEnd:
FHostControl.DoMarkerDragEnd(Event.Marker);
TMapEventKind.MapClick:
if FDragState = MKAnnotationViewDragStateNone then
if FSelectedMarker = nil then
FHostControl.DoMapClick(Event.LatLng)
else
FHostControl.DoMarkerClick(FSelectedMarker);
TMapEventKind.MapLongClick:
if FDragState = MKAnnotationViewDragStateNone then
if FSelectedMarker = nil then
FHostControl.DoMapLongClick(Event.LatLng);
TMapEventKind.MapDoubleClick:
if FSelectedMarker = nil then
FHostControl.DoMapDoubleClick(Event.LatLng)
else
FHostControl.DoMarkerDoubleClick(FSelectedMarker);
end;

// added
if FSelectedMarker = SelectedMarker then
FSelectedMarker := nil;
// end added
end;

Comments are closed.