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

Latest news

Last at Tue, 6 Dec 2011 18:37:53
Topic: New BlackBerry sample app
See more news »

Nutiteq with maps OFFLINE

51 replies [Last post]
mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

Hi to all. I'm trying to use mgmaps lib sdk with netbeans. I want to set my app to load maps from local resources (offline) and not from online resources but I don't know how can I do it. There is someone who can illustrate my step by step how can i include offline maps to my app? (for example: Italy)
Thanks!

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

It depends on from where do you want the maps. For e.g. openstreetmap for Italy you (actually end-user) must download a tile package to phone's memory card. For this there are some guides at http://www.mgmaps.com/cache/

Actual code in application is quite simple (assuming that maps are copied to the /maps directory):

final StoredMap sm = new StoredMap("OpenStreetMap", "/maps", true);
mapComponent.setMap(sm);

You may want to have your own custom graphics (color or image) for missing tiles. Add following lines between code lines above to set own color.

final Image missing = Image.createImage(sm.getTileSize(), sm.getTileSize());
final Graphics graphics = missing.getGraphics();
graphics.setColor(0xFFCCCECC);
graphics.fillRect(0, 0, sm.getTileSize(), sm.getTileSize());
sm.setMissingTileImage(missing);

Also the library has sample "storedmaps" which includes also file directory browser function. You can use this as a base.

/JaakL

mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

I've an error using

final StoredMap sm = new StoredMap("OpenStreetMap", "/maps", true);

highlighting "StoredMap" after "new".

Cannot find symbol
Symbol: costructor StoredMap(java.lang.String,java.lang.String,boolean)
Location: class com.nutiteq.maps.StoredMap

What can I do?

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

Did you add import?
import com.nutiteq.maps.StoredMap;

/JaakL

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

Also check if you have proper library version (1.0.0) in build path, not some older one.

/JaakL

mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

Yes I did

mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

I solve my question "Cannot find symbol" upgrading the lib from 0.1.0 to 1.0.0.

Now I use this site
http://www.mapcacher.com/
for get a .map file (size is less than 1kb) for indicate what area I want.

Then I use this file with gMapMaker app (http://www.mgmaps.com/cache/gMapMaker-setup.exe) to download all data and the program make a folder cache with some folders (example OpenStreetMap_0, OpenStreetMap_1, ...). I put all of these folders into /maps in res directory of my project. Then i use

final StoredMap sm = new StoredMap("OpenStreetMap", "/maps", true);
mapComponent.setMap(sm);

And i try my application without connect to internet but i see only red color without map data.

What's wrong? can you help me?

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

There are two a bit different formats for stored maps:
a) in JAR file (res directory) the files should be named as {zoom}_{x}_{y}.png , without subdirectories. Everything in single directory. This is for small number of files (few MB), and each tile must be in own file, as it is not suggested to make too huge JAR files for applications.

b) in file system of phone or flash drive you should use file structure like gmapmaker uses (with .mgm files). There are subdirectories also. This is for large number of files (up to few GB), and it supports multiple tiles per one file format.

You can convert tiles from the "mgmaps" file format to JAR file simpler format, it is mainly just matter of file naming and directory flattening. We do not have specific script for it, but it is easy to do it. Anyway too large JAR file should be avoided.

/JaakL

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

ps. to use files from JAR file you should use following code instead StoredMap (set zoom levels depending on your content):
mapComponent.setMap(new JaredOpenStreetMap(256, 1, 11));

/JaakL

mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

I've created the structure with .mgm files and all of these files/directories in one directory called "OpenStreetMap". Now how can I import these maps in my application? can you explain me the method step by step? (with code and various step)
Thanks

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

The library package has two sample codes:
a) samples\mapper\src\com\nutiteq\storedmaps : about using .mgm files from phone memory or flash drive (file system). This shows also how enduser can browse to find correct directory

b) samples\mapper\src\com\nutiteq\jarmap : about maps in JAR file. The library samples\mapper\resources directory has also maps (png files) in correct format.

If you want to use .mgm files, then you have to make sure that these are "one tile per file" and you have to rename them to .png. You can check with a picture viewer if these are correct png files. .Mgm is a file format which may have one png file (then you can just rename it) or could have several ones.

/JaakL

mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

I use "jar method" and it works.
With storedmaps i've some problems. I use the file browser like the sample samples\mapper\src\com\nutiteq\storedmaps and finally i use

mapItem.setMap(sm);

But i don't see the map..

the sample uses mapComponent. Is there problems if I use mapItem?

mveggia
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 06/10/2009

I solve it.

dalbani
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 08/24/2009

Hello,

On the same "offline maps" topic, I was wondering if it was supported on the Android platform.
So far I could only get red tiles with stored maps... while it does work correctly with, say, Cloudmade maps.

If I have a directy called "GoogleMap_14" (i.e. zoom 14) containing .mgm files, how should I call the StoredMap constructor ?
Currently I have this in my code:

StoredMap storedMap = new StoredMap("GoogleMap", "/sdcard/maps", false);

where the directory full path is "/sdcard/maps/GoogleMap_14", and I do request a level 14 zoom in the BasicMapComponent constructor.

So what did I do wrong?

Plus I was thinking of the filesystem-related issue. I've tried to implement a JavaIO-based implementation of FileSystem(Connection) for Android but I'm not sure that I'm in the "correct direction" :-)

Any help would be welcome!

Thanks.

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

Yes, you would need to implement FileSystem for Android (i.e. Java IO). Unfortunately library does not include it yet. Probably it will be in the next update.

/JaakL

dalbani
User offline. Last seen 2 years 18 weeks ago. Offline
Joined: 08/24/2009

You're right, I've implemented the FileSystem stuff and it does now work.

FileSystem.readFile(filename) is called an argument like 'sdcard/maps/GoogleMap_14/507_359.mgm|10_4'.
So I can extract the filename part and then parse the .mgm file to get the right tile according to the dx/dy.
By the way, it's not a big deal, but what is the reason of the missing leading '/' in the file path? As I do have implemented FileSystem.getRoots() as returning a single "/" in a Vector.

Thanks

Matrix
User offline. Last seen 2 years 22 weeks ago. Offline
Joined: 08/21/2009

Hi,
Where I can download Stored map of Uzbekistan?

Matrix
User offline. Last seen 2 years 22 weeks ago. Offline
Joined: 08/21/2009

Now I download stored map of Estonia.
How can I import these maps in my application.

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

For Stored maps creation see some guides from http://www.mgmaps.com/cache/

For using the maps you copy them to the phone (SD card usually), e.g. directory maps, uncompressed. Then set map type in your code as stored map:

mapComponent.setMap(new StoredMap("OpenStreetMap", "/Memory card/maps", true));

See sample "com.nutiteq.storedmaps" in j2me SDK package. This creates also directory browser for user, so maps directory can be found interactively. On different phones SD card root directory can be named differently, this "Memory card" used in N95 for example.

/JaakL

Larry101
User offline. Last seen 2 years 19 weeks ago. Offline
Joined: 09/15/2009

I have the same problem as those mentioned above. I downloaded the Estonia Maps, unzipped them, put them in a folder called maps in the mass memory of my N95 8GB. The stored maps example works fine when I select the folder using the file browser implemented. But as soon as I try and skip this step, and just hard code the url to the files, the maps don't load (just get red screen). I have tried both:
mapComponent.setMap(new StoredMap("OpenStreetMap", "/Mass memory/maps", true));

and

mapComponent.setMap(new StoredMap("OpenStreetMap", "/E:/maps", true));

but neither works. The log shows a lot of "Could not retrieve E:/maps/OpenStreetMap_1/1.0.mgm" type errors.

Larry101
User offline. Last seen 2 years 19 weeks ago. Offline
Joined: 09/15/2009

To answer my own question, in case anybody else ever has this problem, the following advice in the Javadocs for the library fixed my problem:
Note: to use stored map You need to also insert FileSystem into map component using BasicMapComponent.setFileSystem(FileSystem)

relliknomed
User offline. Last seen 2 years 17 weeks ago. Offline
Joined: 09/03/2009

I need enough information about develop an offline maps application(Android) you could give me information, tutorials or an example about develop offline maps application please help me thanks.

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

I try to used stored maps on my Android app.
I have download the stored map by gMapMaker and I have copied it to sdcard (mgmaps/OpenStreetMap_01,
OpenStreetMap_02 ...)

mapComponent.setFileSystem(new AndroidFileSystem());
mapComponent.setMap(new StoredMap("OpenStreetMap",
"/sdcard/mgmaps", true));

But i only see the red. In logCat i don't see anything. What did I do wrong ?

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

You should get logs to get some hints. Turn on logging of the library:

Log.setLogger(new AndroidLogger("NutiteqLib"));
Log.enableAll();

/JaakL

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

Thanks you, I solved it.
The problem is gMapMaker downloads the stored map and put mgm files into child folder (0,1,2...). I copy these files and put all of them in a folder and it works fine.

tanmay
User offline. Last seen 1 year 32 weeks ago. Offline
Joined: 05/14/2010

How did u flatten the directory structure?? Have you got the script in case you used one ? I am having the same problem. WOuld appreciate your help.

Cheers

rastakais
User offline. Last seen 1 year 46 weeks ago. Offline
Joined: 03/14/2010

hi every one;
i ask how make google map with LWUIT lib in j2me??
I'm stuck :( is there somebody who can help me !!!

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

I don't want to know how to make Google map (as it is not legal).

Regarding LWUIT see http://www.nutiteq.com/maps_lwuit.html . I just updated it and added also a basic sample project with source and compatible LWUIT and Nutiteq libraries.

/JaakL

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

hi jaak,

I am using the api for blackberry, going the StoreMap path (not jar). But i have also realized all my mgm files are put into child folder (0,1,2...).

ie: \maps\OpenStreetMap_0\0\0_0.mgm

I know this is the folder naming setting for multiple tiles per file. But according to its cache.conf, it should be 1tile per file: version=3
tiles_per_file=1
hash_size=97
center=42.525564,-90.000000,1,OpenStreetMap

Is there a way to download the mgm images again but put in the same zoom folder instead of MTPF folder format? Thanks.

==============

Darn, i think that wasn't the only problem. I tried the method that doraenino used by copying all the files from the child directory into one folder, and it still doesn't work.

I logged the errors:
Error > Error in task runner: null
No stack trace
Debug > TW: create new worker
Error > Error reading tile: null
No stack trace
Error > Could not retrieve maps/OpenStreetMap_3/1_2.mgm
Error > Error reading tile: null
No stack trace
Error > Error reading tile: null
No stack trace
Error > Could not retrieve maps/OpenStreetMap_3/0_3.mgm
Error > Could not retrieve maps/OpenStreetMap_3/0_2.mgm
Error > Error reading tile: null
No stack trace
Error > Error reading tile: null
No stack trace
Error > Error reading tile: null
No stack trace
Error > Could not retrieve maps/OpenStreetMap_3/1_2.mgm
needRepaint complete=false
Error > Could not retrieve maps/OpenStreetMap_3/0_3.mgm
Error > Could not retrieve maps/OpenStreetMap_3/0_2.mgm
needRepaint complete=false
needRepaint complete=false

It seems it couldn't find the file, even though i already put the files in the sdcard, ie. G:\maps\OpenStreetMap_3, etc.

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

also tried using
final StoredMap openStreet = new StoredMap("OpenStreetMap", "/SDCard/maps", true);
and
final StoredMap openStreet = new StoredMap("OpenStreetMap", "/sdcard/maps", true);
neither work on simulator or actual device.

im really stuck now. any suggestions?

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

After implementing FileSystem with JSR75FileSystem fs = new JSR75FileSystem();
mapComponent.setFileSystem(fs);
I get another another kind of error. Looks like this time it's actually accessing the right folder and file name. Still having error reading the images and the cache.conf file. What am I missing?

Debug > Loading file:///SDCard/maps/cache.conf
CMM: OilTraxNT(1340) no sig from 0x33
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading cache.conf
No stack trace
Debug > Loading file:///SDCard/maps/OpenStreetMap_6/10_22.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Error > Could not retrieve SDCard/maps/OpenStreetMap_6/10_22.mgm
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/1_3.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/1_3.mgm
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/1_2.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/0_3.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/1_2.mgm
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/0_3.mgm
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/0_2.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/1_3.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/1_2.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/0_3.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/0_2.mgm
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/1_3.mgm
needRepaint complete=false
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/1_2.mgm
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/0_3.mgm
Debug > Loading file:///SDCard/maps/OpenStreetMap_3/0_2.mgm
CMM: OilTraxNT(1340) no sig from 0x33
Error > Error reading tile: File system error
No stack trace
Error > Could not retrieve SDCard/maps/OpenStreetMap_3/0_2.mgm
needRepaint complete=true

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

The file format for 1 tile per file should be /_/_.mgm . There is middle directory level if there is hash_size>0. You have hash_size=97, so this means that files are spread to up to 97 subdirectories (just to avoid too large dir listings), and also tile reader tries to read them from there. You probably want to use setting hash_size=0.

Your another issue comes from file reading in general, cache.conf . BlackBerry is not too generous with debug info, but I suspect that there is something wrong about permissions (does app have file read permissions?) or root directory should be defined differently.

/JaakL

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

thanks jaak.

I got it to work eventually. In end, filesystem was causing all the problems. After correctly setting the filesystem, the naming of the files it tries to fetch from is correctly parsed in the hash97 fashion (ie. /_/_.mgm ).

my code looks like this:
final StoredMap openStreet = new StoredMap("OpenStreetMap", "/SDCard/maps", true);
JSR75FileSystem fs = new JSR75FileSystem();
map.setFileSystem(fs);

shamitha
User offline. Last seen 36 weeks 4 days ago. Offline
Joined: 04/11/2010

Hi,
I am trying to use the stored maps to display maps offline. I tried the sample from library maps-lib-j2me-1_0_2. I stored the maps obtained from gmapmaker in "maps" directory in res folder of my project. When i tried executing MapCanvas midlet, it shows me an exception on emulator saying: "Application cannot be launched. The application may have done an illegal operation. Contact the provider to resolve the issue. Class is not a midlet".
On the output window it shows the following error:
java.lang.InstantiationException: Class not a MIDlet
- com.sun.midp.main.CldcMIDletLoader.newInstance(), bci=41
- com.sun.midp.midlet.MIDletStateHandler.createMIDlet(), bci=66
- com.sun.midp.midlet.MIDletStateHandler.createAndRegisterMIDlet(), bci=17
- com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=27
- com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
- com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
- com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
- com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
Also, in storedMapSample, I get an error as:
java.io.IOException
- javax.microedition.lcdui.ImageDataFactory.createImageFromStream(), bci=8
- javax.microedition.lcdui.ImageDataFactory.createResourceImageData(), bci=45
- javax.microedition.lcdui.Image.createImage(), bci=8
- com.nutiteq.storedmaps.MapCanvas.(), bci=12
- com.nutiteq.storedmaps.StoredMapSample.startApp(), bci=15
- javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
- com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
- com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
- com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
- com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
- com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
- com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26
TRACE: , Exception caught in Display class
java.lang.NullPointerException: 0
- com.nutiteq.storedmaps.MapCanvas.paint(), bci=53
- javax.microedition.lcdui.CanvasLFImpl.uCallPaint(), bci=202
- javax.microedition.lcdui.Display$ChameleonTunnel.callPaint(), bci=33
- com.sun.midp.chameleon.layers.BodyLayer.paintBody(), bci=12
- com.sun.midp.chameleon.CLayer.paint(), bci=46
- com.sun.midp.chameleon.CWindow.paintLayers(), bci=115

please help me detect the bugs.
Thanks!!
Really appreciate any help!!

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

The first error is that something is wrong with your project or building, so the package is not correct Midlet. Can't tell what could be there.

The second issue is IOException. It means that midlet cannot read map file (directory). Maybe permission in JAD file missing, maybe defined file directory is wrong.

/JaakL

chamroeun
User offline. Last seen 1 year 21 weeks ago. Offline
Joined: 08/30/2010

dear all,

i manage to get the offline map work. but on the real mobile(Ex. LG), the problem is File Access permission. it keep asking for every file read. In short, it's not usable.

I understand that i need my midlet signed. but with 500$ for signing, it's not affordable.

Can i make it ask me only once? i.e allow file access till application exits.

Thanks

noksi
User offline. Last seen 21 weeks 4 days ago. Offline
Joined: 08/13/2010

I lost so many time for offline maps. I don't understand what is wrong. The code is so simply. I get this message:

javax.microedition.rms.RecordStoreNotFoundException: deleteRecordStore error: file not found at javax.microedition.rms.RecordStore.deleteRecordStore(+113) at com.nutiteq.cache.RmsCache.initialize(+73) at com.nutiteq.cache.CachingChain.initialize(+22) at com.nutiteq.BasicMapComponent.startMapping(+161) at com.nutiteq.MapComponent.startMapping(+97) at demo.demoCanvas.initialize(+7) at utils.DummyStarter.run(+9)
Debug > Loading file:///maps/cache.conf
Error > Error in task runner: null
java.lang.NegativeArraySizeException at com.nutiteq.fs.JSR75FileSystem.readFile(+62) at com.nutiteq.maps.StoredMap.readConfig(+35) at com.nutiteq.maps.StoredMap.initializeConfigUsingFs(+11) at w.a(+217) at bd.run(+264)
Debug > TW: create new worker
Execution completed.


package Demo;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.MIDletStateChangeException;

import utils.DummyStarter;
import utils.InitializedCanvas;
import utils.LogForm;

import com.nutiteq.MapComponent;
import com.nutiteq.components.WgsPoint;
import com.nutiteq.controls.ControlKeys;
import com.nutiteq.controls.OnScreenZoomControls;
import com.nutiteq.fs.FileSystem;
import com.nutiteq.fs.JSR75FileSystem;
import com.nutiteq.listeners.MapListener;
import com.nutiteq.maps.StoredMap;
import com.nutiteq.ui.DefaultCursor;
import com.nutiteq.ui.DefaultZoomIndicator;
import com.nutiteq.utils.Utils;

public class DemoCanvas extends Canvas implements CommandListener,
MapListener, InitializedCanvas {

public static DemoCanvas instance;

private final Timer timer;
private Thread starter;

private boolean initialized;

private final MapComponent mapComponent;

private Image splash;

private Command exit = new Command("Exit", Command.EXIT, 0);

private final StoredMap sm;
private final FileSystem fs;

public DemoCanvas() {
instance = this;

try {
splash = Image.createImage("/splash.png");
} catch (final IOException e) {
e.printStackTrace();
}

timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
starter = new Thread(
new DummyStarter(Demo.instance, instance));
starter.start();
}
}, 3000);
setFullScreenMode(true);
mapComponent = new MapComponent(
"31fefc0e570cb3860f2a6d4b38c6490d4c88befca6fcc2.94593658",
Demo.instance, getWidth(), getHeight(), new WgsPoint(
20.461693, 44.815454), 16);

fs = new JSR75FileSystem();
mapComponent.setFileSystem(fs);
sm = new StoredMap("OpenStreetMap", "/maps",
true);
mapComponent.setMap(sm);

}

public void initialize() {

mapComponent.startMapping();

if (hasPointerEvents()) {
mapComponent.setOnScreenZoomControls(new OnScreenZoomControls(Utils
.createImage(OnScreenZoomControls.DEFAULT_ZOOM_IMAGE)));
} else {
mapComponent.setCursor(new DefaultCursor(0xFFFF0000));
}
mapComponent.defineControlKey(ControlKeys.MOVE_UP_KEY, -1);
mapComponent.defineControlKey(ControlKeys.MOVE_DOWN_KEY, -2);
mapComponent.defineControlKey(ControlKeys.MOVE_LEFT_KEY, -3);
mapComponent.defineControlKey(ControlKeys.MOVE_RIGHT_KEY, -4);
mapComponent.defineControlKey(ControlKeys.SELECT_KEY, -5);
mapComponent
.defineControlKey(ControlKeys.ZOOM_OUT_KEY, Canvas.KEY_STAR);
mapComponent
.defineControlKey(ControlKeys.ZOOM_IN_KEY, Canvas.KEY_POUND);

mapComponent.defineControlKey(ControlKeys.MOVE_UP_KEY, 38);
mapComponent.defineControlKey(ControlKeys.MOVE_DOWN_KEY, 40);
mapComponent.defineControlKey(ControlKeys.MOVE_LEFT_KEY, 37);
mapComponent.defineControlKey(ControlKeys.MOVE_RIGHT_KEY, 39);
mapComponent.defineControlKey(ControlKeys.SELECT_KEY, 10);

mapComponent.setZoomLevelIndicator(new DefaultZoomIndicator(0, 1));

mapComponent.setMapListener(this);

addCommand(exit);
addCommand(LogForm.SHOW_LOG);

setCommandListener(this);
initialized = true;
repaint();
}

protected void paint(final Graphics g) {
if (!initialized) {
// paint splash
g.setColor(0xFFFFFFFF);
g.setClip(0, 0, getWidth(), getHeight());
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(splash, (getWidth() - splash.getWidth()) / 2,
(getHeight() - splash.getHeight()) / 2, Graphics.TOP
| Graphics.LEFT);
return;
}

g.setClip(0, 0, getWidth(), getHeight());
mapComponent.paint(g);
}

public void mapClicked(WgsPoint arg0) {
// TODO Auto-generated method stub

}

public void mapMoved() {
// TODO Auto-generated method stub

}

public void needRepaint(boolean arg0) {
repaint();
}

public void commandAction(final Command cmd, final Displayable d) {
if (cmd == exit) {
mapComponent.stopMapping();
try {
Demo.instance.destroyApp(true);
} catch (final MIDletStateChangeException ignore) {
}
} else if (cmd == LogForm.SHOW_LOG) {
Display.getDisplay(Demo.instance).setCurrent(
new LogForm(mapComponent, Demo.instance, this));
}
}

protected void keyPressed(final int keyCode) {
if (!initialized) {
return;
}
mapComponent.keyPressed(keyCode);
}

protected void keyReleased(final int keyCode) {
if (!initialized) {
return;
}
mapComponent.keyReleased(keyCode);
}

protected void keyRepeated(final int keyCode) {
if (!initialized) {
return;
}
mapComponent.keyRepeated(keyCode);
}

protected void pointerDragged(final int x, final int y) {
if (!initialized) {
return;
}
mapComponent.pointerDragged(x, y);
}

protected void pointerPressed(final int x, final int y) {
if (!initialized) {
return;
}
mapComponent.pointerPressed(x, y);
}

protected void pointerReleased(final int x, final int y) {
if (!initialized) {
return;
}
mapComponent.pointerReleased(x, y);
}
}

maps folder with genereted OpenStreetMap is in res folder.

noksi
User offline. Last seen 21 weeks 4 days ago. Offline
Joined: 08/13/2010

When I manualy put maps to sdcard, offline maps work. But that's not user frendly. How to do without manualy coping maps to sdcard? I want to only instal midlet on phone and then offline maps works...

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

There is no live SD card writing feature for offline maps in J2ME, maybe you expect this? There are following options:
1) Add this feature (like it exists for Android)
2) Add application code which preloads maps and write to SD card. We have this solution for Android, but it is not part of the library.

If you are interested in one of the features, please email to sales@nutiteq.com

/JaakL

koharudin
User offline. Last seen 25 weeks 6 days ago. Offline
Joined: 05/28/2009

Hi, i have a big map file. Then i calibrated it. I want to slice the map into 256x256 tile map. I want to convert it into stored map, so my application can load that map. is it possible in nutiteq? slicing my map then use it for stored map?

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

Yes, this is the way. There is tool called gdal2tiles.py as part of free GDAL library, and it should create suitable map tiles from large GeoTIFF file (and from many other raster formats). Have not tried it yet through.

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

Hi,
i'm trying to use the nutiteq-lib to set my app to get the maps offline. I have downloaded the example with the Estonia-Map and I save the files ("EstOsm"-Folder with subfolders) in the folder "/sdcard/maps". It's important for me to save the files on the sdcard of the phone and not on the phone.
I use following code (in the onCreate-Function)..:

...
final StoredMap sm = new StoredMap("OpenStreetMap", "/sdcard/maps", true);
mapComponent = new BasicMapComponent("tutorial", "Nutiteq", "Android Mapper", 1, 1, new WgsPoint(24.764580, 59.437420), 10);
mapComponent.setMap(sm);
mapComponent.setPanningStrategy(new ThreadDrivenPanning());
mapComponent.setControlKeysHandler(new AndroidKeysHandler());
mapComponent.startMapping();
mapView = new MapView(this, mapComponent);
...

But this does not work.
I see only a red color in the Map-View, that means that the map-data could not be loaded.
Why is this so..?

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

It seems you have not set filesystem for the mapComponent. This is also needed before startMapping. Next step would be to add logging for the library and see what are log messages in console - like what files exactly are searched for.

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

And how can i make this..? (I mean to set filesystem for the mapcomponent).

When i add the log for the nutiteq library, i got the following error-logs..:

03-07 16:50:38.164: ERROR/NutiteqLib(641): Could not retrieve sdcard/maps/OpenStreetMap_10/582_300.mgm

03-07 16:50:38.304: ERROR/NutiteqLib(641): Error reading tile: null

.
.
.
//The same error also with the files 582_299.mgm, 581-300.mgm, 581_299.mgm, 582_301.mgm, 581_301.mgm, 583_300.mgm, 583_299.mgm, 583_301.mgm, all in the same folder(OpenstreetMap_10)

It's strange, that the above mentioned files do not excist in the EstOsm Folder or Subfolders..!

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

Filesystem definition depends on platform.

Android:

mapComponent.setFileSystem(new AndroidFileSystem());

J2ME/BlackBerry:

mapComponent.setFileSystem(new JSR75FileSystem());

If it searches for files what you do not have then maybe map center and/or zoom is set to location or zoom what is not included to the map data package. You can try to go to zoom 0, which should be covered globally.

/JaakL

Nafi
User offline. Last seen 8 weeks 3 days ago. Offline
Joined: 03/04/2011

I have made a stupid mistake. I wrote..:

final StoredMap sm = new StoredMap("OpenStreetMap", "/sdcard/maps", true);

...but the OpenstreetFiles were in "/sdcard/maps/EstOsm"-Folder.
Now it works fine.

Thank you for helping..!

-Nafi-

srandroid
User offline. Last seen 41 weeks 1 day ago. Offline
Joined: 04/15/2011

Android & StoredMap
Hi ,

I m trying to test the sample about StoredMap but ,
I have systematicly the folowing kind of error :

Error reading tile: /sdcard/mymaps/OpenStreetMap_10/71/609_531.mgm

I learned the hole of the discussions above , but I didnt found a solution for my problem.

this is my code :

mapComponent = new BasicMapComponent("tutorial", "Nutiteq", "Android Mapper", 1, 1, new WgsPoint(34.017625, -6.836545), 10);
mapComponent.setFileSystem(new AndroidFileSystem());
StoredMap storedMap = new StoredMap("OpenStreetMap","/sdcard/mymaps",true);
mapComponent.setMap(storedMap);

I generated my map exactly how it's described at this url http://www.mgmaps.com/stored/

There is someone who can help me?
thx for advance

aymentouhent
User offline. Last seen 39 weeks 2 days ago. Offline
Joined: 04/20/2011

Hi all,

I'm using offline maps with ANDROID also and I'm facing the problem of the red rendering

I generate my mgm map and the structure is the following
----------------
/sdcard/mgmaps/openstreetmap_{zoom}/{file}.mgm

{zoom} is set from 10 to 17

The code lines :
----------------
mapComponent = new BasicMapComponent("nutiteqId", "zommara","MyProject", 1, 1, new WgsPoint(Slong, Slat), 15);
mapComponent.setFileSystem(new AndroidFileSystem());
mapComponent.setMap(new StoredMap("openstreetmap","/sdcard/mgmaps", true));

Any help please
the problem of te red rendering persits

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

If you have in log something like:
Error reading tile: /sdcard/mymaps/OpenStreetMap_10/71/609_531.mgm

1. check with some Android file browser whether you have exactly this file.
2. check your cache.conf file contents from the /sdcard/mymaps directory

/JaakL

kvy04
User offline. Last seen 5 weeks 4 days ago. Offline
Joined: 07/20/2011

Hi,
I managed to run the stored map in J2ME, by using map tiles downloaded using gMapMaker. Now i'm wondering if it is possible to add icons and path(one point to another point)on that stored map?
I know that it is possible to do the things above using online map.
If possible can someone guide me how to do it on stored map? btw, i'm new to J2ME, and still learning.

Thank you.

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

All actions: add Places (ie Points), Lines and Polygons and KML overlays is same for online map and offline map, no differences in API regarding this. You can also add online services like routing and routes to it, but of course it would not be completely offline application then.

/JaakL