Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Uudised

Viimane: Tue, 6 Dec 2011 18:37:53
Teema: New BlackBerry sample app
Veel uudiseid »

Android : OnMapElementListener => OnMapElement

15 replies [Last post]
micka
User offline. Last seen 2 years 1 week ago. Offline
Joined: 01/14/2010

Hi,

thanks you very much for your works,
i'm just a student who makes some research about your awesome application ^^

my problem is that i need to use the OnMapElementListener, but it seems that there is not function implemented yet.

by example :

OnMapElementListener toto=new OnMapElementListener() {
@Override
public void elementLeft(OnMapElement arg0) {
Log.d("test","test1 "+arg0.getLabel() );
}
@Override
public void elementEntered(OnMapElement arg0) {
Log.d("test","test2 "+arg0.getLabel() );
}
@Override
public void elementClicked(OnMapElement arg0) {
Log.d("test","test3 "+arg0.getLabel() );
}
}

in my case, it generates an error :
java.lang.RuntimeException: hasCode() not implemented!
at com.nutiteq.components.PlaceLabel.hashCode(Unknown Source)
at java.lang.Object.toString(Object.java:255)
at java.lang.StringBuilder.append(StringBuilder.java:209)
at micka.Mapper$3.elementEntered(Mapper.java:124)

and what kind of object i use ? it's from kml

in my case i need to click on object and getting the name of this object, is that possible ? what can i do ?

thanks you very much and i apologie for my bad english :(

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

Your issue is that getLabel() of OnMapElement returns Label, and you try to print it out; printing asks hash for objects and this is not implemented there. You should use getLabel() method of the Label to get the String. Something like:

Log.d("test","test3 "+arg0.getLabel().getLabel());

Right, this looks confusing.

For Android and KML context I suggest to take a look to http://code.google.com/p/textopia-android/source/browse/ project sources. This is quite simple app, but it uses many KML advanced features.

/JaakL

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

ps. you probably do not want actually Label text, you want name of the Place (and maybe other KML parameters). In KML service the Label is same as Name. Then you need something like that

if (element instanceof Place) {
Place p = (Place) element;
System.out.println("Name "+p.getName());
}

/JaakL

micka
User offline. Last seen 2 years 1 week ago. Offline
Joined: 01/14/2010

thank you very much it works great !

doraenino
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 12/27/2009

Hello, i have a problem when i use OnMapElementListener.

I have a list of Places show on Map. I have implemented my Activity by OnMapElementListener, and i have override elementClicked(OnMapElement arg0)
but I when i click on a Place, it doesn't jump to elementClicked(OnMapElement arg0)?

Please help me.

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

Have you activated OnMapElementListener for MapComponent with something like following?

mapComponent.setOnMapElementListener(this);

/JaakL

doraenino
User offline. Last seen 1 year 42 weeks ago. Offline
Joined: 12/27/2009

Thanks you.
I forgot to activate OnMapElementListener for MapComponent. It works fine.

Luismi
User offline. Last seen 1 year 39 weeks ago. Offline
Joined: 11/27/2009

Hello
I have a problem to add places to map. I´m using the method addPlace. If I use this method before starMapping the place appear in the map, buf if I try to add a place after this, I don´t see anything in the map. I think, but I not sure, that y don´t refress the map, but I don´t now how to do this.
In the documentation I found examples for JavaME,where use a ImagWraper.
I only know add elements to map using the google maps API adding a Overlay.

Sorry for my horrible English.

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

I cannot replicate the issue: places are displayed in both cases. Please try also with latest library version from http://nutiteq.com/beta/lib/

/JaakL

sasquatchsoftware
User offline. Last seen 1 year 18 weeks ago. Offline
Joined: 05/10/2010

hi jaak,

Im using the blackbbery api, and ran into a little problem implementing the OnMapElementListener.

I implemented the interface, elementEntered, and elementLeft worked, but elementClicked doesn't seem to do anything. Might you know what is causing this?

sasquatchsoftware
User offline. Last seen 1 year 18 weeks ago. Offline
Joined: 05/10/2010

i think the blackberry native navigationClick method if overriding the elementClicked. So i changed the navigationClick to go to elementClicked manually, however this way I do not have the OnMapElement object that is clicked. Is there a better work around?

protected boolean navigationClick(int status, int time) {
fieldChangeNotify(1);
return true;
}

protected void fieldChangeNotify(int context) {
try {
map.getOnMapElementListener().elementClicked(null); //i have the OnMapElement object here
//this.getChangeListener().fieldChanged(this, context);
} catch (Exception e) {
}
}

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

what do you expect to happen with navigationClick? maybe you want to find out where is cursor currently (center of screen) and call pointerPressed and pointerReleased on this? Or maybe keyPressed with selection key code: then map object will handle this as element selection, and would find out selected element and fire Element selected event. Hopefully this gives some ideas.

/JaakL

Kishore
User offline. Last seen 49 weeks 2 days ago. Offline
Joined: 01/31/2011

Hi Jaak,

In Android once I put a place, how do I move the same pointer/marker to some new location?

How to implement that,like drag n drop?

Regards,
Kishore

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

Currently only way would be to remove marker from old place and then add it to the new place. There is no movement as such.

/JaakL

Kishore
User offline. Last seen 49 weeks 2 days ago. Offline
Joined: 01/31/2011

Hi Jaak,

How do I get a new coordinate to add a Marker?
Please help me.

As I observed, first OnTouchListener, then MapElementListener and then MapListener will be called when I click on any OnMapElement/Place object, so I will get the corresponding OnMapElement (to remove), but then how I to get the new position to place a new Place object?

Regards,
Kishore

jaak
User offline. Last seen 11 hours 35 min ago. Offline
Joined: 06/19/2008

Basic idea would be that you'll get screen coordinates from the touch event and need to convert it to geographical ones to add new place.

One way would be to use getBoundingBox() of MapComponent to get current map area (in geographical coordinates), and based on touch coordinates and screen size find out approximate geographical location of touch release.

/JaakL