Calling .map file in my app

112 views
Skip to first unread message

Federico

unread,
Feb 3, 2011, 9:45:57 AM2/3/11
to mapsforge-dev
Hi,

I've tried to follow your instructions in order to include an offline
map in my application. I've downloaded a map from OpenStreetmap,
converted it into a .map file using MapFileWriter and then used it for
my app.

Everything works fine. But I need to copy the .map file into the SD
Card. I would know if it is possible to integrate the map file in the
app, as we integrate, for example, images... I use Eclipse and I put
images into the "drawable" directory: I would like to know if
something similar is possible with my .map file.

Best regards,

Federico (from Italy)

mueh...@inf.fu-berlin.de

unread,
Feb 3, 2011, 11:31:22 AM2/3/11
to mapsfo...@googlegroups.com, Federico
Hello Federico,

that's a good question. The problem is, that a java.io.RandomAccessFile
instance is needed in order to read the map data from a binary map file.
Just having an InputStream is not enough, as it doesn't have a seek()
method. Calling skip(n) is not the same. In worst case all n bytes will
be read, which is not an option for huge map files.

Unfortunately, Android does not offer seekable file access on resources.
That is due to the way all resource files are packaged and compressed
into one .apk file. A quick Google search reveals that many other people
are having the same problem. One work around may be to copy the file to
the SD card or internal phone filesystem when your application is
started for the first time. See:
http://groups.google.com/group/android-developers/browse_thread/thread/59b6bf70ca6d2081

But depending on the file size, this copying process may take a longer
time. Having map files bundled with your application will also increase
the size of your APK file a lot. Another disadvantage is that the map
file can no longer be updated separately or copied to other devices.

Best regards,
Thilo

signature.asc

Federico

unread,
Feb 4, 2011, 5:21:27 AM2/4/11
to mapsforge-dev
Hi Thilo,

thanks for your kind reply! I will try to do what you suggest.

Thank you again,

Federico



On 3 Feb, 17:31, "muehlb...@inf.fu-berlin.de" <muehlb...@inf.fu-
berlin.de> wrote:
> Hello Federico,
>
> that's a good question. The problem is, that a java.io.RandomAccessFile
> instance is needed in order to read the map data from a binary map file.
> Just having an InputStream is not enough, as it doesn't have a seek()
> method. Calling skip(n) is not the same. In worst case all n bytes will
> be read, which is not an option for huge map files.
>
> Unfortunately, Android does not offer seekable file access on resources.
> That is due to the way all resource files are packaged and compressed
> into one .apk file. A quick Google search reveals that many other people
> are having the same problem. One work around may be to copy the file to
> the SD card or internal phone filesystem when your application is
> started for the first time. See:http://groups.google.com/group/android-developers/browse_thread/threa...
>
> But depending on the file size, this copying process may take a longer
> time. Having map files bundled with your application will also increase
> the size of your APK file a lot. Another disadvantage is that the map
> file can no longer be updated separately or copied to other devices.
>
> Best regards,
> Thilo
>
> On 03/02/11 15:45, Federico wrote:
>
> > Hi,
>
> > I've tried to follow your instructions in order to include an offline
> > map in my application. I've downloaded a map from OpenStreetmap,
> > converted it into a .map file using MapFileWriter and then used it for
> > my app.
>
> > Everything works fine. But I need to copy the .map file into the SD
> > Card. I would know if it is possible to integrate the map file in the
> > app, as we integrate, for example, images... I use Eclipse and I put
> > images into the "drawable" directory: I would like to know if
> > something similar is possible with my .map file.
>
> > Best regards,
>
> > Federico (from Italy)
>
>
>
>  signature.asc
> < 1KVisualizzaScarica
Reply all
Reply to author
Forward
0 new messages