Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marker LatLng Jackson Parser Exception #31

Open
jimbok8 opened this issue Jan 25, 2021 · 2 comments
Open

Marker LatLng Jackson Parser Exception #31

jimbok8 opened this issue Jan 25, 2021 · 2 comments

Comments

@jimbok8
Copy link

jimbok8 commented Jan 25, 2021

I have found a new problem when creating a Marker from a LatLng value of an existing Marker and adding it to a map.
THis error is thrown:
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "alt" (class com.vaadin.addon.leaflet4vaadin.types.LatLng), not marked as ignorable (3 known properties: "altitude", "lng", "lat"])
at [Source: (String)"{"lat":51.463353808734574,"lng":-0.30032978947940125,"alt":0}"; line: 1, column: 61] (through reference chain: com.vaadin.addon.leaflet4vaadin.types.LatLng["alt"])

This is the code that adds the marker (getMarker() gets an existing marker from a HashMap and retrieves its LatLng value) :

String cirString = "<svg xmlns='http://www.w3.org/2000/svg' width='1000' height='1000'><circle cx='500' cy='500' r='460'  stroke='#ff00ffff' stroke-width='80' fill='none'/></svg>";
String cirIconUrl = new String("data:image/svg+xml," + cirString.replace("#", "%23"));
Icon cir = new Icon(cirIconUrl, null, null);
int size = 51;
cir.setIconSize(Point.of(size, size));
cir.setIconAnchor(Point.of(size / 2, size / 2));
cir.setPopupAnchor(Point.of(size / 2, size / 2));
cir.setTooltipAnchor(Point.of(size / 2, size / 2));

Marker m = getMarker(gs);
LatLng highlightLatLng = m.getLatLng();
highlighter = new Marker();
highlighter.setLatLng(highlightLatLng);
highlighter.setIcon(cir);
highlighter.addTo(leafletMap);
highlighter.setZIndexOffset(999);

Is this a bug?
Thanks
Jim

@jimbok8 jimbok8 changed the title MArker LatLng Jackson Parser Exception Marker LatLng Jackson Parser Exception Jan 25, 2021
@jimbok8
Copy link
Author

jimbok8 commented Jan 25, 2021

Just noticed from the Leaflet reference that LatLng has an 'alt' property NOT an 'altitude' property.

Property | Type | Description
lat | Number | Latitude in degrees
lng | Number | Longitude in degrees
alt | Number | Altitude in meters (optional)

I think this may affect the Jackson XML parsing.

@jimbok8
Copy link
Author

jimbok8 commented Jan 26, 2021

Is this the error?
In:
src/main/resources/META-INF/resources/frontend/leaflet-type-converter.js

I think altitude should be alt, in order to align with the Leaflet LatLng property.

 * Convert the given JsonObject to Leaflet LatLng
 */
toLatLng(latLng) {
  return latLng ? L.latLng(latLng.lat, latLng.lng, latLng.altitude) : latLng;
}```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant