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!
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?
Did you add import?
import com.nutiteq.maps.StoredMap;
Also check if you have proper library version (1.0.0) in build path, not some older one.
Yes I did
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?
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.
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));
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
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.
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?
I solve it.
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.
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.
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
Hi,
Where I can download Stored map of Uzbekistan?
Now I download stored map of Estonia.
How can I import these maps in my application.
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.
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.
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)
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.
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 ?
You should get logs to get some hints. Turn on logging of the library:
Log.setLogger(new AndroidLogger("NutiteqLib"));
Log.enableAll();
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.
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
hi every one;
i ask how make google map with LWUIT lib in j2me??
I'm stuck :( is there somebody who can help me !!!
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.
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.
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?
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
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.
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);
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!!
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.
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.
Also the library has sample "storedmaps" which includes also file directory browser function. You can use this as a base.
/JaakL