Comments (7)
Thanks - I will look at it asap ..
from jxmapviewer2.
just wanted to let you know. I've also tried to add other Swing components, e.g., JPanel: the bug (?) is always the same, position is always top center.
from jxmapviewer2.
The original example from java.net are heavily outdated - still, the code should work. I was not able to reproduce the problem.
This is why I've created a new sample that uses JXMapKit and a roll-over tooltip.
Does this solve your problem?
from jxmapviewer2.
Okay I think I've found the issue. I was iterating over a bunch of items and checked whether there was one item within a certain distance to the mouse pointer. If so, I set its position and breaked the for-loop. If not, I was calling tooltip.setVisible(false) and continued to check for the next item. Calling all these setVisible(false) before the first (and final) setVisible(true) made the functionality somehow broke. Here the broken code:
for (DataItem di : twitterDataManager.getDataItems()) {
GeoLocation gl = twitterDataManager.getGeoLocation(di);
...
// check if near the mouse
if (screenPos.distance(e.getPoint()) < 20) {
mytip.setLocation(screenPos);
isVisible = true;
break;
} else {
mytip.setVisible(false);
}
}
And this is the version that works:
boolean isVisible = false;
// iter over all tweet locations
for (DataItem di : twitterDataManager.getDataItems()) {
GeoLocation gl = twitterDataManager.getGeoLocation(di);
...
// check if near the mouse
if (screenPos.distance(e.getPoint()) < 20) {
mytip.setLocation(screenPos);
isVisible = true;
break;
} else {
}
}
mytip.setVisible(isVisible);
So this still might be a bug, which is however caused by calling repeatedly setVisible(false) before actually calling setVisible(true) and setting the proper position.
from jxmapviewer2.
However, I am experiencing flickering now. It seems like the label initially pops up at the top center position for a short time, before actually being displayed at the correct position.
This is an excerpt of the important lines of code, I think the flickering is not caused by my code but rather by some odd Swing / JXMapViewer behaviour?
if (closestDataItem != null) {
tooltip.setDataItem(closestDataItem);
tooltip.setLocation(closestScreenPos);
tooltip.setVisible(true);
} else {
tooltip.setVisible(false);
}
Here a video showing the flickering effect.
https://www.youtube.com/watch?v=XheubIIH-L8
from jxmapviewer2.
I can confirm this, but I cannot explain the jumping behaviour of the tooltip. Please let me know if you find the reason for that.
from jxmapviewer2.
Alright, if I find something, I'll let you know here :-)
from jxmapviewer2.
Related Issues (20)
- Cache Input Stream can leak resources HOT 1
- Add Automatic-Module-Name clause to jar manifest HOT 6
- Showing Pin on Map HOT 1
- Google Maps is not working with jxmapviewer2 HOT 2
- Can we load shape files on top of the map for jxmapviewer2? HOT 3
- Improvement suggestion HOT 4
- Is it possible to update routes? HOT 3
- Divided by zero ArithmeticException in AbstractTileFactory (v2.6) HOT 2
- Strange behavior in overlay painting from zoom 2 down to 0 HOT 5
- JavaFX compatibility HOT 2
- AbstractTileFactory#tileMap causing OutOfMemory after long usage HOT 3
- JxMapViewer.zoomToBestFit(fitPoints, 0.4) throws exception HOT 4
- Feature: decorate tile urls with query params HOT 1
- Feature: Modern httpClient HOT 7
- OOM and cache HOT 2
- Help Needed: Using MouseEvents to create new GeoPoint HOT 5
- Newest release does not support Java Modules HOT 3
- Using a WMS with other CRS/SRS (other then WGS84 EPSG:4326): HOT 2
- Possible race condition in FileBasedLocalCache HOT 1
- New release? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jxmapviewer2.