[iOS][New Arch] Marker onPress/onSelect/onDeselect `position` is always {0,0}: Fabric wrapper reads x/y from the coordinate dict, and AIRMapMarker measures against a nil calloutView
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 76/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- ios, objective-c, react-native
- Domínio
- mobile
Direção de pesquisa
Start with ios/AirMaps/RNMapsMarkerView.mm and ios/AirMaps/AIRMapMarker.m, focusing on the three marker event handlers and the _handleTap: coordinate calculation. Run the mentioned XCTest bundle against the real app build and verify that marker press, select, and deselect payloads report tap positions in map-view coordinates rather than {x: 0, y: 0}.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Summary
On iOS with the New Architecture (Fabric), the position in a marker's onPress, onSelect and onDeselect payload is always { x: 0, y: 0 }. Two separate bugs produce this, one in the Fabric wrapper and one in AIRMapMarker (Apple Maps provider):
ios/AirMaps/RNMapsMarkerView.mmbuilds thepositionstruct from the coordinate dictionary:coordinateDict[@"x"]/coordinateDict[@"y"]. A coordinate dictionary only haslatitude/longitude, sox/yare nil and read as 0. This happens in all three handlers (onPress,onDeselect,onSelect; lines 115, 144 and 231 on master). ThepositionDictis fetched right above and never used.ios/AirMaps/AIRMapMarker.m_handleTap:computes the marker-press point as[recognizer locationInView:self.calloutView]. When no callout is openself.calloutViewis nil, andlocationInView:nilreturns the point in the window's coordinate space rather than the map's. In practice on our app it reported{0, 0}; even where it does not, it is not in map coordinates, which is what the map-levelonPresspayload uses.
Together they mean a marker tap on iOS carries no usable finger position, so an app cannot do its own hit-testing on a marker press (we needed this because MapKit resolves a tap against the annotation view's whole rectangular frame, so in a dense pack of custom pins the neighbour gets selected).
Reproducible sample code
<MapView style={{ flex: 1 }} initialRegion={{ latitude: -41.29, longitude: 174.78, latitudeDelta: 0.02, longitudeDelta: 0.0092 }}>
<Marker
coordinate={{ latitude: -41.29, longitude: 174.78 }}
onPress={(e) => console.log('marker', e.nativeEvent.position, e.nativeEvent.coordinate)}
/>
</MapView>
Steps to reproduce
- New Architecture enabled, Apple Maps provider (
PROVIDER_DEFAULT). - Tap the marker.
Expected result
position is the tap point in the map view's coordinate space, e.g. { x: 201, y: 387 }, matching what MapView.onPress reports for a map tap.
Actual result
position is { x: 0, y: 0 } on every marker press.
Fix
Both hunks are from a patch we run in production (patch-package against 1.29.0; the code is unchanged on master as of v1.29.2).
--- a/ios/AirMaps/RNMapsMarkerView.mm
+++ b/ios/AirMaps/RNMapsMarkerView.mm
@@ -110,10 +110,10 @@
NSDictionary* coordinateDict = dictionary[@"coordinate"];
NSDictionary* positionDict = dictionary[@"position"];
facebook::react::RNMapsMarkerEventEmitter::OnPressPosition point = {
- .x = [coordinateDict[@"x"] doubleValue],
- .y = [coordinateDict[@"y"] doubleValue],
+ .x = [positionDict[@"x"] doubleValue],
+ .y = [positionDict[@"y"] doubleValue],
};
The same two-line change applies to the onDeselect (line 144) and onSelect (line 231) handlers.
--- a/ios/AirMaps/AIRMapMarker.m
+++ b/ios/AirMaps/AIRMapMarker.m
@@ -289,7 +289,7 @@
// the actual marker got clicked
- CGPoint touchPointReal = [recognizer locationInView:self.calloutView];
+ CGPoint touchPointReal = [recognizer locationInView:marker.map];
id event = @{
@"action": @"marker-press",
A related change we also carry, which you may or may not want: in AIRMapMarker -setupTapGestureRecognizer (or wherever the tap recogniser is attached), tapGestureRecognizer.cancelsTouchesInView = NO lets MKMapView independently hit-test the same touch and select a different overlapping annotation. Setting it to YES stops that; the handler already calls selectAnnotation: itself.
React Native Maps Version
1.29.0 (bug present on master, v1.29.2)
What platforms are you seeing the problem on?
iOS
React Native Version
0.86 (Expo SDK 57), New Architecture
What version of Expo are you using?
SDK 57
Device(s)
iPhone 17 Pro simulator (iOS 26.5), iPhone hardware
Additional information
Verified with an XCTest bundle hosted by the real app build that drives AIRMapMarker / RNMapsMarkerView through the runtime and reads the JS-side press payload back; reverting each hunk in node_modules fails exactly its test. A full write-up will be at https://zackdesign.biz/which-pin-did-you-tap/ shortly.
- Linguagem predominante
- TypeScript
- Estrelas
- 16k
- Forks
- 5k
- Merge médio
- 1d 4h
- PRs com merge (30d)
- 4
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de react-native-maps/react-native-maps
-
[Android] onMarkerClick calls showInfoWindow() on markers that have no info window, raising them above every zIndexTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
react-native-maps/react-native-maps#6006 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
react-native-maps/react-native-maps#6005 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
react-native-maps/react-native-maps#6003 ·
Mantenedores costumam responder em até 2 dias
-
onPress/onLongPress `position` is in device pixels on Android, points on iOSTalvez já em andamento @ivan-kolesov assumiu há 28 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
react-native-maps/react-native-maps#5998 ·
Mantenedores costumam responder em até 2 dias
-
Fabric: ReactViewGroup cannot be cast to MapMarker in MarkerManager.onLayoutChange (leaked layout listener on recycled views)Talvez já em andamento @huytdps13400 assumiu há 42 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
react-native-maps/react-native-maps#5987 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
Todas as issues de react-native-maps/react-native-maps
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
NousResearch/hermes-agent#136483 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Mantenedores costumam responder em até 1 dia
-
Tool errors containing cycles or BigInt crash getErrorMessage and replace the original failureAbertafactory-active factory-automatic task-bug-reproduction-success task-identify-harness-labels-done task-identify-issue-type-done
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
vercel/ai#22796 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
[Bug]: Web chat input doesn't regain focus after a reply finishesTalvez já em andamento @GaijinSystems assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
zeroclaw-labs/zeroclaw#11658 ·
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
babylonlabs-io/babylon-toolkit#2711 ·
Mantenedores costumam responder em até 1 dia