Select to view content in your preferred language

How to define location for an Overlay ?

2152
4
Jump to solution
03-28-2013 05:58 AM
JeremieJoalland1
Deactivated User
I want to add multiples overlays to my map.

For example, I add NavigatorOverlay and ScaleBarOverlay like this :

NavigatorOverlay navigator = new NavigatorOverlay(); jMap.addMapOverlay(navigator);  ScaleBarOverlay scaleBar = new ScaleBarOverlay(); jMap.addMapOverlay(scaleBar);


The problem is that the 2 overlays are displayed at the same location on my map (bottom-left by default), so I tried to move one of them by playing with .setLocation(), but nothing change.

How can I display one Overlay on top-left of may map for example ? or any other location ?
(And if my application JFrame change, how can I be sure that overlay position will foloww correctly ?)
0 Kudos
1 Solution

Accepted Solutions
EricBader
Honored Contributor
Hi Jeremie:

The Scalebar overlay always places the scalebar in the lower left. It cannot be repositioned.
The Navigator overlay defaults to the same location, but you can call setLocation(Point pt) to postion it to the top left.

View solution in original post

0 Kudos
4 Replies
EricBader
Honored Contributor
Hi Jeremie:

The Scalebar overlay always places the scalebar in the lower left. It cannot be repositioned.
The Navigator overlay defaults to the same location, but you can call setLocation(Point pt) to postion it to the top left.
0 Kudos
JeremieJoalland1
Deactivated User
Thanks, now it's working fine if I used java.awt.Point :

NavigatorOverlay navigator = new NavigatorOverlay();
navigator.setLocation(new java.awt.Point(10, 10));
myJMap.addMapOverlay(navigator);  


I was using "navigator.setLocation(10, 10);", but it wasn't working...

I also confirm this is not possible to change location of a ScaleBarOverlay (no error/exception but setLocation() do nothing).
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
I also confirm this is not possible to change location of a ScaleBarOverlay (no error/exception but setLocation() do nothing).


Keep in mind that the ScaleBarOverlay is an MapOverlay object that doesn't override the setLocation(Point pt) method. You can create your own, or simply extend it, and implement the method by following its example. To get a perspective on how it works, you'd have to have access to its source by setting the toolkit properties in eclipse to point to it in order to gain access to original code.

[ATTACH=CONFIG]23127[/ATTACH]

Once this is set, double-click on it, or press F3 on a reference to it in code, to see its implementation.
0 Kudos
JeremieJoalland1
Deactivated User
Thanks for the tip about getting Toolkit sources (I'm still new on Java !)
0 Kudos