mapbox / mapbox/mapbox-maps-flutter
MyPoint extends Point does not return values
Personne n'a encore pris cette issue.
- Langage dominant
- Dart
- Étoiles
- 380
- Forks
- 204
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Hi all
As there is no active discussionsomewhere I ask my question here, event it is not the place to do.
I need to Extend Points with a PointID to be able to load data of this point later in the code
This is how I initialise Points
pointAnnotationManager?.create(PointAnnotationOptions(
geometry: **MyPoint(
coordinates: Position(
double.parse(place.attributes!.longitude.toString()),
double.parse(place.attributes!.latitude.toString()),
),
pinNumber: place.id,
trailPinNumber: place.id,
).toJson(),**
textField: "${place.id}",
///ToDo Set textOpacity to 0 when no text should be displayed
textOpacity: 1,
textOffset: [0.0, -4.0],
iconOpacity: 0.5,
iconSize: 0.75,
iconOffset: [0.0, -30.0],
symbolSortKey: 10,
image: selectedImageData,
));
The next step is reading a point when Clicked
class AnnotationClickListener extends OnPointAnnotationClickListener {
_MapBoxMapScreenState mapState;
Animation<double>? animation;
AnimationController? controller;
AnnotationClickListener(this.mapState);
@override
void onPointAnnotationClick(PointAnnotation selectedannotation) async {
if (await mapState.mapboxMap.style.styleSourceExists("source")) {
await mapState.mapboxMap.style.removeStyleLayer("layer");
await mapState.mapboxMap.style.removeStyleSource("source");
}
// build route from puck position to the clicked annotation
final start = await mapState.mapboxMap.style.getPuckPosition();
**final end = MyPoint.fromJson((selectedannotation.geometry)!.cast());**
final coordinates = await fetchRouteCoordinates(start, end.coordinates, ZadaApp.mapboxAccessToken);
final selectedpinNumber = end.pointid;
final selectedtrailPinNumber = end.trailspointid;
**print('PinInformation: ${end.pointid}');**
**print('TrailPintInformation: ${end.trailspointid}');**
}
}
here is the toJson and fromJson Funcion to serialise end deserialise
part 'utils.g.dart';
@JsonSerializable(explicitToJson: true)
class MyPoint extends Point {
int? pointid;
int? trailspointid;
MyPoint({
super.bbox,
required super.coordinates,
this.pointid,
this.trailspointid
});
@override
factory MyPoint.fromJson(Map<String, dynamic> json) => _$MyPointFromJson(json);
@override
Map<String, dynamic> toJson() => super.serialize(_$MyPointToJson(this));
@override
MyPoint clone() => MyPoint(coordinates: coordinates.clone(), bbox: bbox?.clone(), pointid: pointid, trailspointid: trailspointid);
@override
int get hashCode => Object.hashAll([
type,
...coordinates,
if (bbox != null) ...bbox!,
if (pointid != null) pointid!,
if (trailspointid != null) trailspointid!,
]);
@override
bool operator == (Object other) => other is MyPoint
? coordinates == other.coordinates
: false;
}
The output of end.pointid is always empty in the code
print('PinInformation: ${end.pointid}');
print('TrailPintInformation: ${end.trailspointid}');
Any hit are welcome many thanks for your help
Roman
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner MyPoint.toJson et MyPoint.fromJson dans la classe présentée, puis comparez-les avec la sérialisation générée par utils.g.dart. Suivez les points d’entrée de la création de PointAnnotation et de AnnotationClickListener.onPointAnnotationClick, et vérifiez que pointid et trailspointid survivent à la sérialisation et sont disponibles après le clic.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- dart, flutter
- Domaine
- mobile
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100