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

Latest news

Last at Mon, 6 Sep 2010 12:27:06
Topic: Let your feedback ideas flow
See more news »

Nutiteq on Twitter

12 weeks 1 day ago Nutiteq is proud sponsor of StateOfTheMap 2010 #sotm10

Android : OnMapElementListener => OnMapElement

11 replies [Last post]
micka
User offline. Last seen 32 weeks 22 hours 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 6 hours 36 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 6 hours 36 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 32 weeks 22 hours ago. Offline
Joined: 01/14/2010

thank you very much it works great !

doraenino
User offline. Last seen 21 weeks 6 days 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 6 hours 36 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 21 weeks 6 days ago. Offline
Joined: 12/27/2009

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

Luismi
User offline. Last seen 17 weeks 6 days 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 6 hours 36 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 14 weeks 6 days 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 14 weeks 6 days 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 6 hours 36 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