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

Bug fixe + Enhancement #4

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/com/vaadin/addon/leaflet4vaadin/LeafletMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.vaadin.addon.leaflet4vaadin;

import elemental.json.JsonType;

import java.io.IOException;
import java.io.Serializable;
import java.util.Optional;
Expand Down Expand Up @@ -535,7 +537,13 @@ public <T extends Serializable> CompletableFuture<T> call(Identifiable target, S
javascriptResult.then(value -> {
try {
ObjectMapper objectMapper = new ObjectMapper();
T result = objectMapper.readValue(value.toString(), resultType);
// Detect object type for value to be handled correctly (ex: getZoom)
JsonType type = value.getType();
T result;
if ( type.equals(JsonType.OBJECT))
result = objectMapper.readValue(value.toString(), resultType);
else
result = objectMapper.readValue(value.asString(), resultType);
completableFuture.complete(result);
} catch (IOException e) {
throw new RuntimeException("Failed to parse javascript result", e);
Expand Down Expand Up @@ -603,4 +611,4 @@ public MapReadyEvent(LeafletMap source) {
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public class Marker extends InteractiveLayer implements SupportsDragEvents, Mark
private boolean riseOnHover = false;
private int riseOffset = 250;
private int autoPanSpeed = 10;


/**
* Allow to associate a user object to the marker
*/
private Object object;

public Marker() {
super();
setBubblingMouseEvents(false);
Expand Down Expand Up @@ -169,6 +174,14 @@ public void setAutoPanPadding(Point autoPanPadding) {
this.autoPanPadding = autoPanPadding;
}

public Object getObject() {
return object;
}

public void setObject(Object object) {
this.object = object;
}

public String getAlt() {
return alt;
}
Expand Down