Results 1 to 2 of 2
  1. #1
    TomTom1 is offline Member
    Join Date
    Jul 2016
    Rep Power

    Default Setting a marker in google maps API automatically

    Hey guys,

    I`m trying to realise a tracking application with FXML. I`m using an AnimationTimer where I'm executing the webscript and set a new marker:

    My java code looks like this:
    Java Code:
            timer_Tracking = new AnimationTimer() {
                public void handle(long timestamp) {
                    try {
                        double ar[] = FileImport.getGpsPosition();
                        double Ltd = ar[0];
                        double Lng = ar[1];
                                    + " = " + Ltd + ";"
                                    + "window.lon = " + Lng + ";"
                                    + "document.updateMarker(, window.lon);");
                    } catch (IOException ex) {
                        Logger.getLogger(GoogleMapsController.class.getName()).log(Level.SEVERE, null, ex);
    And this is the corresponding method in the html file:
    Java Code:
    document.updateMarker = function (x, y) {
            var latLng = new google.maps.LatLng(x, y);
    The problem is, if I execute this buy clicking on a button, the marker gets redrawn fine, however in my AnimationTimer the old marker is not deleted. So I end up with a bunch of markers.
    However, if I scroll out/in while this process is going on the old markers are deleted. But, certainly the old ones should be deleted all the time. But I don't know how do this.

    Thanks in advance for suggestions!

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Setting a marker in google maps API automatically

    I am unfamiliar with JavaFX and JavaScript but this behavior can happen in pure Java by
    not calling the parent class paint routine. So for any inherited, overridden, paint method paint(),
    do this:

    Java Code:
    public void paint(Graphics g) {
      // rest of code
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 1
    Last Post: 08-04-2016, 10:42 AM
  2. Replies: 1
    Last Post: 02-19-2014, 06:25 PM
  3. Google Earth or Maps in GUI
    By spyroth in forum SWT / JFace
    Replies: 1
    Last Post: 02-12-2011, 07:24 PM
  4. google maps static api on java se
    By shubham.velocity in forum Networking
    Replies: 2
    Last Post: 11-14-2010, 10:09 PM
  5. Google Maps API
    By mew in forum New To Java
    Replies: 0
    Last Post: 12-26-2007, 10:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts