-
-
Notifications
You must be signed in to change notification settings - Fork 29
Labels
androidAndroid specific issueAndroid specific issuebugSomething isn't workingSomething isn't working
Milestone
Description
Platforms
Android
Version of flutter-maplibre
maplibre: ^0.3.3+1
Bug Description
When clicking on map, i got event from onEvent. If this event is MapEventClick, and devicePixelRatio is 1 then i got all my features on that point. But when my devicePixelRatio is higher, then i got features from other place on map.
Steps to Reproduce
click on map, check features where clicked, with devicePixelRatio that is not 1 i got wrong features
Expected Results
I should got correct features for point. I suspect
| screenPoint: screenLocation.toOffset() / pixelRatio, |
Actual Results
I got wrong features. I can workaround it by calling
final newPoint = Offset(
event.screenPoint.dx /
MediaQuery.of(context).devicePixelRatio /
MediaQuery.of(context).devicePixelRatio,
event.screenPoint.dy /
MediaQuery.of(context).devicePixelRatio /
MediaQuery.of(context).devicePixelRatio,
);so it is square wrong. Most likely / is used instead of *
Code Sample
working code with workaround, newPoint transformation needed.
onEvent: (event) async {
if (event is MapEventClick) {
debugPrint('Map clicked at ${event.point}');
if (_mapController != null) {
final newPoint = Offset(
event.screenPoint.dx /
MediaQuery.of(context).devicePixelRatio /
MediaQuery.of(context).devicePixelRatio,
event.screenPoint.dy /
MediaQuery.of(context).devicePixelRatio /
MediaQuery.of(context).devicePixelRatio,
);
final features = _mapController!.featuresAtPoint(newPoint);
for (var feature in features) {
final properties = feature.properties;
final featureType = properties['feature_type'];
final country = properties['country'];
final sourceId = properties['source_id'];
if (featureType != null ||
country != null ||
sourceId != null) {
debugPrint(
'Feature Clicked: info: $featureType, $country, $sourceId',
);
} else {
debugPrint('Feature Clicked: $feature');
}
}
}
}
}Reactions are currently unavailable
Sub-issues
Metadata
Metadata
Assignees
Labels
androidAndroid specific issueAndroid specific issuebugSomething isn't workingSomething isn't working
Projects
Status
Done