Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8681721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:35:02+00:00 2026-06-12T21:35:02+00:00

Hello Stack Overflow community, I am a Java newbie and I am doing a

  • 0

Hello Stack Overflow community,

I am a Java newbie and I am doing a simple java project where I take coordinates (lat and lon) from a (dynamic) source and use JMapViewer (Yes, not JXMapViewer) to display the markers on a map. I have put all the coordinates in two ArrayList(s).
It looks like that:

for(int i = 0; i < latArrayList.size(); i++){
    map.addMapMarker(new MapMarkerDot((double)latArrayList.get(i), (double)longArrayList.get(i)));
}

EDIT: map is a jMapViewer object.

And it works pretty fine.
The problem is I need this map to refresh every 20 seconds using a Timer and the only way I found was to close and open the map, like this:

    theMap.setVisible(false);
    theMap  = new Map();
    theMap.setVisible(true); 

EDIT: theMap is an object (jFrame not jMapViewer) I create in the main function (like in the demo) and I can’t use addMapMarker on it (like theMap.addMapMarker(150.2,150.2))

and well, as you can imagine this is pretty annoying (every 20 seconds the window closes and opens and the previous ‘browsing’ session is lost). So is there a way to refresh it? By adding markers dynamically or just refreshing the content?

Thanks a lot.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:35:03+00:00Added an answer on June 12, 2026 at 9:35 pm

    I have never used that API but it looks like theMap.removeAllMapMarkers(); would do the trick. You can then start adding new markers again.

    Regarding your loop, if you declared your Lists with generics you would not need to cast to double:

    List<Double> latArrayList = new ArrayList<Double> ();
    latArrayList.add(125.87); //or whatever
    
    for(int i = 0; i < latArrayList.size(); i++){
        theMap.addMapMarker(new MapMarkerDot(latArrayList.get(i), longArrayList.get(i)));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello Stack Overflow community, I am doing multistep processing on some data I am
Hello Stack Overflow community, I'm in the process of learning WP7 development, I'm struggling
Hello again Stack Overflow. you probably remember me from my unit spawning problem in
Hello again, stackoverflow community! I'm working on writing a simple blog system in Rails,
Hello there Stack Overflow, I hope you'll help me with my very first question
First off - hello, this is my first Stack Overflow question so I'll try
Hello there people of stack overflow, I have just started developing with android and
Hello everyone this is my first post on stack overflow.com I am trying to
Hello good Stack Overflow people, I do have a business problem and would like
Hello good people of Stack Overflow, I am having trouble with an application I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.