Showing my raster map on mobile app (iOS/Android) - android

I'd like to show a map on my app and handling some events within it. I'm also need to load a background raster map to it (dwg format, which is the AutoCAD format for raster, but it doesn't really matter, since it can be converted to any other known format), doesn't matter if the file is local or remote.
I know very well how to id on desktop, but which options I have on mobile?
Thanks!

You have TileOverlays on Android and Tile Layers on iOS, which can both use remote and local data source.

Related

Android OpenStreetMap tracker available offline

I'm new at osmdroid and I'm trying to build simple GPS tracking application that must work offline. So first of all I know that osmdroid works with .osm But how to download osm file directly to my android device and more importantly how later I need to use it. I dont understand .osm file is simply just xml with lots of coordinates and other data. So how that .osm file can be transform to a graphical map? I know that is necessary to parse .osm file to get data, but where to download actual graphical map?
osmdroid does not currently present .osm data, mainly due to performance reasons. osmdroid does render raster images that someone can capture into a zip or database and then transfer to device. The problem really is space. It's a big planet and getting raster images can be huge! You'd have to prepare geographic regions into a database then host them somewhere and have your app download them on demand.
osmdroid as a wiki on offline maps here:
https://github.com/osmdroid/osmdroid/wiki/Offline-Map-Tiles
An alternative approach is something like Mapsforge, which can preconvert .osm data into their own binary format, also chunked up by geographic region. Same rules apply, however the file/download sizes are much smaller. Support for osmdroid using Mapsforge is in beta at the moment, however mapsforge can run on it's own and has it's own demo apps and whatnot.
To transform the .osm file into a graphical map, you need something like renderd and a slew of other tools, all on open street maps wiki. Again, you need a boat ton of storage for the planet to convert it into raster images. Then you'd still have to package them somehow and get them on device.
Or you can just use online maps.

Can Android handle computations in image processing and ttf rendering?

I am planning to create an Android application that will enable users to draw their own font. One similar app I found, they render the drawings online and sends the ttf file via email. What I want in my study is to render offline and saves the ttf directly into the sd card. Do you think Android can possibly do it? I am worried if it can handle all the computations of the first step which is image processing and handle those parameter requirement in rendering into .ttf (TrueType) format.
There's no reason why it wouldn't be able to.
If you can't find a API function that can do this, you can always write a small native library (using NDK), and use the FreeType open source library to do the rendering.
If you need an example of character rendering to OpenCV images, look in this short code:
https://github.com/amirgeva/optmatch/blob/master/src/chrmatch/ftfont.cpp

Use of Planet.osm with osmDroid for offline maps

does anyone know if it is possible to build an Android application using osmDroid that makes use of Planet.osm stored on an SD card?
for example, you would store Planet.osm on a large SD card that has been put in a phone. The application loaded on the phone would then look in the SD card for the relevent maptiles and allow the user to have a full map offline.
No, not as you would expect it.
The Planet contains raw vector data whereas osmdroid needs pre-rendered raster tiles. You would need a renderer on your mobile device but rendering is a very ressource-intensive task and not really suited for mobile devices. Unless you are using pre-processed data (and ideally a vector renderer) as done by multiple mobile apps like OsmAnd. Storing pre-rendered tiles could be an option, but only for limited areas as their storage requirements increase very fast.
You can take a look at mapsforge if you intend to add vector rendering to your application.

How to make map tiles load more efficiently using leaflet with an android app?

I am currently developing an android application that features a map using phonegap, cloudmade and leaflet. Is there a way I can somehow cache the map tiles on the android phone? Loading the map tiles from the server each time is quite slow.
This is only theoretic considerations and I don't known working implementations for leaflet. However I have some issue, but don't have time now to resolve it.
Web and phonegap storages:
loacalstorage - synchronous, easy to implement with base64 url, small size 2.5-5MB (probably phonegap resolve localstorage small size issue).
indexed db and web sql - asynchronous, size 50 MB (maybe more).
phonegap file storage - asynchronous.
How implement:
Write own layer which will work with your storage, probably it will be difficult for asynchronous APIs.
You always can store tile as data url with base64 encoding. You can transform image by server url to data url with JS and canvas.
If you can use tile preloading easiest way to use file storage, because you can just use links to tiles on your file system.
For asychronous APIs you always can detect your tile by zoom, latitude and longitude: insert fake tile with zoom_lat_lng id and fake src, check tile in storage by this id, if tile found - load it, else load from server with caching.
UPD: See my caching solution with indexed db and web sql for example:
https://github.com/tbicr/OfflineMap/tree/master/leaflet_idb_sql_site and example http://tbicr.github.com/OfflineMap/leaflet/index.html (now not fast on android).

Best way to deal with big (shape-)data for map in Android Application

I am building the prototype for an Android app that should result in a versatile map that can deal with a large but static amount of environmental data combined with (user-generated) data that will be hosted on a separate platform.
My current approach is to fetch the large static data via Google Fusion Tables (in original a shape file - .shp, .dbf, .shx that I have exported as a .kml with QGisMaps - the "smaller" .kml I am using is already 66.4MB, the one intended for final use over 140 MB...) I know it is possible to slice down .kml but will this have an effect on loading times?
You can see a current example of the shape data on Google Maps here https://www.google.com/fusiontables/DataSource?snapid=S717313eWaJ
But now I am wondering if I am on the right path at all since this one layer of data is loading very slowly on my machine and I am not aware of the hassle to put this map into an Android app - and more importantly also fetching more data from a separate server and putting it as another (filterable) layer on top of it. This layer will be collected data from users, thus not "static" but regularly updated - integer values displayed in color per geodata.
Several people hinted me to use Open Street Maps but some advised that Android is very eloquent with Google Maps - in the middle of development I thought maybe someone can tell me whether I chose the right direction to go for or are most likely facing less problems with an alternative solution.
I would be really glad if someone could advise me on the issue with combining map data from two different sources layerd onto one map in Android whereas one bunch of data is huge but static and the other user-generated values.
Thanks so much for your time and looking over this
best
Birgit
EDIT #1: I am now switching to Open Street Maps, hoping to be able to set up a GeoServer myself hosting the data and querying the WMS with the App. It seems like the size of the data still has to be compressed in some way, I will keep you updated.
I'll not be able to address all of your concernes, but I can share some of my experience with maps and ovelays.
The most important concept you must be aware is the memory heap. Each android application has a maximum memory amount that can be used to allocate data objects, called memory heap. This limit is different from device to device and can go from 16MB in small older devices to 64MB in new tablets.
Having said that, you will never be able to load all your data at one shot if the data structure required to hold it exceeds the maximum heap available for the application.
Also, usaging large amounts of memory makes your application better candidate to be terminated by users or by the SO when additional memory is required by critical activities (like a phone call).
Now, going to the maps part...
I've used Google maps as well as mapsforge api for OpenStreet maps. Google maps requires internet connection, while mapsforge enables you to use a local map file or online connection. OpenStree maps don't provide the sattelite view.
Regarding performance, online connection tends to be faster, as they download already rendered map images, while offline map requires the images to be rendered as needed. Mapforges can use a local cache to improve this a little.
Displaying Overlays:
I've used both API's to display paths with arround 10.000 points over a map, together with additional overlays (compass, scale bar, pop-ups, etc.) and the code runs smoothly in a mid-rande device. However, my code have some optimizations to reduce recreation of paths (when user zoom or move map) by transforming the already existing path.
good luck.
So this is how I eventually converted a .shp file into a format that could be displayed by OSMdroid's XYTilesource.
I exported the layers separately as .kml projected WGS84 and imported them as layers to TileMill. After having defied the colors for each layer in CSS, I exported my map as a set of MBTiles. I uploaded them to Mapbox.com. From there I can fetch the tiles which are in the format a.tiles.mapbox.com/v3/myUsername.myTiles/{z}/{x}/{y}.png in my OSMdroid Mapview.
final myTileSource tileSource = new XYTileSource("myTiles", null, 10, 16, 256, ".png", "http://a.tiles.mapbox.com/v3/myUserName.myTiles/");

Categories

Resources