dlsc-software-consulting-gmbh / GMapsFX

Java API for using Google Maps within a JavaFX application.
http://rterp.github.io/GMapsFX/
Apache License 2.0
319 stars 119 forks source link

Markers not appearing. #186

Open PythonSyntax1 opened 5 years ago

PythonSyntax1 commented 5 years ago

I am running into a very strange issue where saved markers are appearing as they should, but when I add a new marker into the marker list, the new marker either does not appear, or every single marker fails to appear.

This is the code I run when I switch between modes with my choicebox. When I first run the program, I load saved LatLongs into the Marker List. Markers disappear and appear perfectly fine when I switch between modes.

   if (choiceBox.getValue().equals("Journal")) {
        map.addMarkers(Main.getProgram().getJournalMarkerList());
        Main.getProgram().setJournalMode();
        resetListView(2);
        System.out.println("JM");
    } else {
        map.addMarkers(Main.getProgram().getGoalMarkerList());
        Main.getProgram().setGoalMode();
        resetListView(1);
        System.out.println("GM");
    }
}

However, when I run a method that adds a Post, which adds a marker to the JournalMarkerList or the GoalMarkerList, they fail to load on my map. Even if I switch between modes with the code above, they still fail to load. I have checked that the new Marker is in the Marker List. The strange thing is that, the way I'm adding a Marker when I make a post, and the way I'm adding a Marker when I'm loading saved Markers, is exactly the same, so I don't understand why one is appearing and the other is not.

Here is my MarkerList class :

public Marker makeNewMarker(LatLong loc) {
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(loc);
    Marker marker = new Marker(markerOptions);
    return marker;
} 

public void addJournalMarkerList(LatLong loc) {
    Marker marker = makeNewMarker(loc);
    journalMarkerList.add(marker);
}

public void addGoalMarkerList(LatLong loc) {
    Marker marker = makeNewMarker(loc);
    goalMarkerList.add(marker);
}

public ArrayList<Marker> getJournalMarkerList() {
    return journalMarkerList;
}

public ArrayList<Marker> getGoalMarkerList() {
    return goalMarkerList;
}

}