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, 17 May 2011 13:21:59
Teema: Nutimap Eesti kaardi asemele
Veel uudiseid »

IllegalThreadStateException and GPS

6 replies [Last post]
wmartinez
User offline. Last seen 1 year 40 weeks ago. Offline
Joined: 01/27/2010

Hello.
I'm developing in JDE 4.7, and I follow the tutorials to get the map updated with the GPS movement, but it does not move at all. It seems the LocationAPIProvider does not work.
Since the App defines a javax.microedition.location.LocationListener to get location notification for other parts of the app, it was suggested to me that the listeners get in conflict.

So, I tried creating my own LocationSource (UserLocationSource) and whenever I get a location update, I do:
WgsPoint here = new WgsPoint( locationData.getQualifiedCoordinates().getLongitude(),
locationData.getQualifiedCoordinates().getLatitude());
setLocation(here);

And setLocations does:
if (locationMarker != null) {
locationMarker.setLocation(location);
}

I do the normal:
marker = new NutiteqLocationMarker(
new PlaceIcon(gpsPresentImage, 16, 16),
new PlaceIcon(gpsConnectionLost, 16,16),
1000, true);
dataSource.setLocationMarker(marker);
map.setLocationSource(dataSource);

And and sent the emulator to simulate GPS movement. It moves! But after 4 or 5 seconds I get:
IllegalThreadStateException in TaskWorker with a null detail.

Have you seen this? Any other way to make the Map follow the GPS?

Thanks!

William Martinez.

wmartinez
User offline. Last seen 1 year 40 weeks ago. Offline
Joined: 01/27/2010

Update:
It turns out that it has nothing to do with the datasource.

The exception is thrown at
Line 97 of com.nutiteq.task.TasksRunnerImpl
cause by BasicMapComponent.startMapping() at line 309.

I have two screens, each has one Map component. I do startMapping() on each. Whenever I do this, the error is shown. It seems although I have two instances of map, they share the same thread at Taskrunner, and thus whenever one is running and the other tries to run, I got the thread exception.

That means I cannot have two maps running at the same time.

William.

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

Yes, your conclusion seems to be correct. There is shared thread for tasks, so currenly you cannot have several map components in the same time.

/JaakL

venkatesh92
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 07/22/2010

hi jaak,

How to create several map Component at same time..

any idea.

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

What is your use case? Right now there are internal parts of the code which are optimized in a way that it is not safe to have multiple Map components within single app.

/JaakL

venkatesh92
User offline. Last seen 1 year 26 weeks ago. Offline
Joined: 07/22/2010

Not multiple mapComponents........

I have list of locations..

if i click one location map screen showing..

Am giving back to list page..

selecting next location means it showing
IllegalThreadSafeException

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

I guess you should use one MapComponent and use methods to move center location of it when list state changes. Maybe your code tries to make new MapComponent with each new map screen.

/JaakL