How can I implement map in my android app. using mapsforge lib (avoiding the creation of map or reading a map file) ?
Can I download tiles from OSM server ?
In this article they demonstrate only offline mode.
Take a look at Mapsforge's sample code at https://code.google.com/p/mapsforge/source/browse.
DownloadLayerViewer demonstrates how to get tiles from the OSM Mapnik server. (Do check OSM's Tile Usage Policy before using this in an app!)
There is also a class for OpenCycleMap, which works in the same way.
If you want to use a custom tile source, take a look at DownloadCustomLayerViewer. This example shows you how to specify the URL from which you want to donload the tiles.
The tile downloading feature has been removed. See this discussion on the mapsforge mailing list. If you only need that specific feature, you can revert to an older revision. I can't remember the exact revision but it should be a revision that was released about one month before the linked comment.
Related
I am working on an android application which contains modules like offline maps.I want to download map (data set) of a particular area based on user input then user can select two locations start and destination and i need to draw routes on the map. can any one please help me to solve this problem.
mapsforge was built just for that. It is incorporated into many projects.
GitHub: mapsforge
Mapsforge gives you full android samples that demonstrates the usage of the offline mapping infrastructure with the usage of their Android libraries.
In addition, the map tiles are free and can be downloaded from here
How we can use mapbox-android-sdk library for offline Maploading in android and how we can add MBTiles and Vector tiles for draw offline Map in android ?
I have create a project in which i have use mapbox-android-sdk library by this is load map only in online . Now what should i do for that .
Have a look at Brad's answer here for how to dynamically save/cache tiles.
Using mbtiles looks to be fairly straightforward and is briefly outlined here.
Please take a look at the following mapbox android offlical example link to download offline map in mapbox android SDK :
https://www.mapbox.com/android-docs/maps/examples/download-a-simple-offline-map/. In order to give user an option to download a region in map - create a map screen so that user can select a particular location to download. From that selected location as shown in the example we have to pass the top-right point of map (north-east) and bottom-left point of map (south-west) point of map as attribute, so that the particular location will be downloaded. Mapbox recommends to use the offline locations plugin so that it will be downloaded asynchronously. Please refer this link for offline locations plugin : https://www.mapbox.com/android-docs/plugins/overview/offline/
I have a project , android application with offline Map. user should download map once, or It should come with the app and then without internet be able to make marks and so on.
Can you give me Idea, which maps should I use, and little example . Thanks
You can use osmdroid
osmdroid is a (almost) full/free replacement for Android's MapView class. It also includes a modular tile provider system with support for numerous online and offline tile sources and overlay support with built-in overlays for plotting icons, tracking location, and drawing shapes.
Also see osmbonuspack
I am currently working on a school project and I am trying to learn the techniques on downloading OSM map tiles into the phone's local memory/cache, so that users are able to view the maps when offline.
This is to be done by giving a specific location, and the map tiles that are within specific radius/distance from the location will be downloaded into the phone memory (when there is online connection) for offline display.
However, I am having some slight trouble in understanding OSMDroid's APIs. From my understanding, it seems that the classes involved are:
MapTileBase
MapDownloader
IFilesystemCache
Please do correct me if I'm mistaken.
Also, in MapTileBase (which I believe is the provider), the getMapTile returns android.graphics.drawable.Drawable.
Is this Drawable class even related to the concept of offline map display?
Hope someone can enlighten me on where exactly maps are being called to be downloaded into the phone's memory, and how we can edit the maps to display interface items such as routes, pins, etc.
I don't have an exactly answer as you're looking for a method to cache offline outside of an area the MapView hasn't already navigated to. The built in caching support is there, but not exactly how you want to do it.
You're going to need online download capabilities if you plan to cache and not just supply your own offline map tiles. I would take a look at the MapTileDownloader and maybe try to implement your own version of it. The MapTileDownloader.TileLoader.loadTile() method takes a MapTileRequestState which I believe the MapTileProviderArray calls when a map tile is needed.
If you can replicate the existing MapTileDownloader's TileLoader functionality, you can probably inject your own relative MapTileRequestState or straight up MapTile's to the one requested. e.g. Take the TileLoader called MapTileRequestState, inspect it, figure out how to construct new MapTileRequestState/MapTile representing tiles outside the current view. It won't be easy though as you'll have to deal with the different zoom levels, and depending on the zoom level, the radius should be smaller, etc... A lower zoom level of 18 would have a larger tile radius than a higher 10.
Personally I was recently working on trying to work 100% offline so I don't have any example code to help. Good luck even though its been a couple of months.
First, go right the source
https://github.com/osmdroid/osmdroid
There's a few wiki articles that will help, especially the offline map tiles article. In short, use MOBAC or the tool osmdroid provides. OSMBonuspack also has a tool to perform the same task on device.
Map tiles are actually downloaded using this class
https://github.com/osmdroid/osmdroid/blob/master/osmdroid-android/src/main/java/org/osmdroid/tileprovider/modules/MapTileDownloader.java
I am a bit stuck with an idea of offline maps in android application.
I want to use Open Street Maps. But how can I redesign their styles and then use in my project? By the way, the resource, I am looking for, has to be free..
Are there any good tutorials about this? I am new to this, so would be thankful for any helpful information.
Here are the basics:
Raster tiles are awful. To my mind, this approach of mobile mapping is very old-fashioned and has no advantages (unless your plan is to make a very bad-looking application).
The other thing is vector tiles. All the data is saved in much more efficient way and can be displayed very beautifully.
And the solutions (nominees) are:
Mapsforge - thanks to #dkiselev
OSMAnd app - thanks to #dkiselev
Mapbox GL (the android version has no releases now, but they are working really hard on it). If you really like mapbox, you can think about
Mapbox Android SDK, which uses raster tiles, but I believe, that
switching to Mapbox GL will not be that hard, when the GL lib will be released.
AirBNB AirMapView - open source and has release version
Urban Labs Sputnik Demo - also interesting solution, but I didn't use it.
Mapzen Open - open source android app, that uses all the best from everywhere. - winner!
And by the way, mapbox gl actully allows rendering your own mapping data (from your own provider). There is a closed issue on github about that, opened by me couple of days ago, and very good answer by one of the project developers.
If you don't care about using your own data source and want to rapidly implement custom (not google/apple) maps into your project - there are dozens of solutions for you as well. You could think of Mapbox, Scobbler, GetYourMap or, again, just google it to find more. There is actually a great article on OSM website about most popular libraries and apps for android ever developed.
Finally, I wish you good luck with your mapping project. And never forget:
if you can't find something doesn't mean it really doesn't exist
- probably you've just been searching not enough.
Offline raster tiles cache
If you need to show your map offline with custom style, you may use any kind of OSM renders. http://wiki.openstreetmap.org/wiki/Rendering
For the case of several cities, I would recommend you http://wiki.openstreetmap.org/wiki/AlaCarte or http://wiki.openstreetmap.org/wiki/TileMill
Create your own style, and export map tiles to sqlite db archive.
After that, you will need to create your own TileProvider for OSMDroid library. This answer could help you How to use MOBAC created OSMDroid SQLite tile source file offline?
Offline vector tiles.
Getyourmap
If you need more than just rendering with custom style, you may use:
https://getyourmap.com/ it's OSM vector renderer. But there would be some problems with accessing raw data to create routing and searching.
OSMAnd
And maybe the hardest but the best way, is to use OSMAnd. It's open-source, there are lots of capabilities, but it's an application, not a component or library.
So if you want to create a stand alone app. you will need to cut off features which you don't need.
Mapsforge
https://github.com/saintbyte/mapsforge It's opensource so it would be possible to add routing and searching. Style, as I know may be customized, but I haven't try it.