Skip to content

Commit

Permalink
Merge pull request #98 from GeoffCapper/master
Browse files Browse the repository at this point in the history
addMarkers method with facility to assign a UI event handler to each …
  • Loading branch information
Rob Terpilowski authored Feb 17, 2017
2 parents a38fc12 + f352317 commit e6d5e65
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public String registerHandler(GFXEventHandler handler) {
* there, but there is only the stop() method on the MouseEvent?
*
* @param callbackKey Key generated by the call to registerHandler.
* @param result Currently the LatLng object from the Google Maps event.
* @param result Currently the event object from the Google Maps event.
*/
public void handleUIEvent(String callbackKey, JSObject result) {
if (handlers.containsKey(callbackKey) && handlers.get(callbackKey) instanceof UIEventHandler) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@
import com.lynden.gmapsfx.javascript.event.StateEventHandler;
import com.lynden.gmapsfx.javascript.event.UIEventHandler;
import com.lynden.gmapsfx.javascript.event.UIEventType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Point2D;
import javafx.util.Callback;
import netscape.javascript.JSObject;

/**
Expand Down Expand Up @@ -235,6 +234,19 @@ public void addMarkers(Collection<Marker> col) {
});
}

public void addMarkers(Collection<Marker> col, UIEventType type, Callback<Marker, UIEventHandler> h) {
if (markers == null) {
markers = new HashSet<>(col);
} else {
markers.addAll(col);
}
col.forEach((m) -> {
m.setMap(this);
addUIEventHandler(m, type, h.call(m));
});
}


/** Removes the markers in the supplied collection from the map.
*
* @param col
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
* @author Rob Terpilowski
*/
public class Marker extends JavascriptObject {


protected String title;


/**
* Contructs a new map Marker with the specified options
Expand All @@ -38,13 +34,16 @@ public Marker(MarkerOptions markerOptions) {
}


public String getTitle() {
return invokeJavascriptReturnValue("getTitle", String.class);
}

/**
* Sets the title of this Marker
* @param title The Marker's new title
*/
public void setTitle( String title ) {
invokeJavascript("setTitle", title);
this.title = title;
}


Expand Down

0 comments on commit e6d5e65

Please sign in to comment.