Graphic below specific area in some Android Map API - android

I'm looking form maps API that would allow me to put pattern in some form (maybe graphic) below forest area, to have something like this (image below) and not only plain colour. Later on I would need to put such images on different areas and roads, also ability to put some 3D building on map would be great.
I found only ways of adding 3D objects and chagning area colours. Maybe I'm using bad words but only results on stackverflow and google were for custom background in markes.
Can you recommend some map API? (If you have some open-source project where I can see how its done it would be awesome. Thank you for your help.

After a lot o research I found the solution. It is to use mapbox with it's vector tiles.
proiblem - area overlay:
Using mapbox styles you can use background-pattern,
fill-pattern, line-pattern, fill-extrusion-pattern, or icon-image properties to overlay specific area type, so you can have even SSJ Blue Songo face covering whole forests :D. Vector tiles same as google API can be also colored as you like.
problem - 3D objects
3D objects like buildings can be placed in desired position, I even found some screanshots with mapbox and car placed on map.
Additionally it seams that when using Vector tiles you can use isometric view. Not yest tested, but form this tutorial it looks like it is possible. For all that hate paying for map services I found that you can host your own tile server and it will works as long as you provide tiles that are compatible with their tile specification.

Alternative solution I decided to use is to render vector tiles on your own. There are two good services to obtain tiles:
Mapbox tiles in MVT format - any zoom, to get tile just use link https://api.mapbox.com/v4/mapbox.mapbox-terrain-v2,mapbox.mapbox-streets-v7/{z}/{x}/{y}.mvt?access_token={access_token}
MapTiler Tilehosting tiles in PBF format - zoom max 14, PBF format is basically same as Mapbox MVT (same parsers might be used), to get tile just use link https://free.tilehosting.com/data/v3/{z}/{x}/{y}.pbf?key={access_token}
When decoding thies some Polygons might not parse properly, here is answer for that question:
Mapbox vector tile MVT is missing data
Rendered tiles can be used with google API by TileOverlay, this gives all Google API features and it is easy to use (mMap.setMapType(GoogleMap.MAP_TYPE_NONE); to disable all google map labels). Downside is of course tile rendering that needs to be done on your won, but for me this is positive, because I have full control on what is displayed (I use OpenGL ES, I recommend EGL14, off-screen rendering here).

Related

How to add custom layer to Google Maps

I am developing an android app in which I am capturing location using Google Maps API v2. I have a large satellite image ( greater than 500 mb ), this image is geo-coded. We need to display this as one of the layers in the Google Maps like Google map has a choice for satellite imagery. How can it be done. As for using tile overlay we need tiles but I have a single image and that to it is very big in size so I cannot use ground overlay also. I am kind of stuck right now.
Try this instead of custom layer overlay we add
https://developers.google.com/maps/documentation/android-api/tileoverlay
This is doable but you're going to have to do more. You will use Tile Overlays method, but since your file is too big, you'll be needing to cut it in equal dimensions, 256dp for example.
To cut your big map file in tiles you'll be using MapTiler. The software will do the cutting for you and will generate the map files. Kudos for this thread for the additional info.

OSMdroid and MBTiles: get area information

I am planning to build sort of a geography quiz app where you have to touch inside the borders of the searched country. So, I have to display a map (I want it to be offline) and be able to test the user click against the map in some way.
I've been searching a while now and found good OSM material from Natural Earth Data and TileMill for converting it to a MBTiles-file (sqlite-database containing all the png's and some meta-data too (using UTFGrid)).
On the Android-side, I would like to use OSMdroid for displaying the maps, mainly because it's open-source and highly maintained.
I've found some guides on how to use the MBTiles-database inside osmdroid but is there also an easy way to access the metadata or check otherwise if the user touched inside the right country area? I would like to avoid some sort of "boundary boxes"...
Any help is highly appreciated!
I'm pretty sure that bounding box calculation is best option.
Can you access metadata from the offline tile source? Yes, kind of. You can get a list of unique tile sources in the archive but that's it. There's an open issue regarding getting the bounds of a given offline archive. You can follow it here (or contribute)
https://github.com/osmdroid/osmdroid/issues/174
It's slightly complex because offline tiles are going to have a bounds per layer/source and per zoom level. There's also no guarantee that that bounds of that given zoom/layer is going to be contiguous. I.E. one zoom level can have both the US and western Europe in it.

Mapbox GL using external maps

I want to use Mapbox GL in my Android application. This service is going to be released soon and I have a tricky question about using the renderer.
I like the renderer itself, but I really want to use my own maps data in the application (not the data, offered by Mapbox and which is paid). For instance, I want to parse OpenStreetMaps data on my own, customise it somehow and then put inside of a renderer to show it in my application.
And now the question: is it possible to use my own maps data while using Mapbox GL? Or it can be only used with Mapbox data?
Thank you in advance for any help. Maybe you know any other well-done solutions for this problem? The thing is, that I want to have vector tiles, not the raster ones. And this project is planned to be developed for iOS later..
You can use MapBox open-source SDK with your own tiles. The Mapbox Native renderer for Android, iOS or Node.JS can be used directly with tiles hosted outside of MapBox.com platform.
See the sample mobile app "OSM2VectorTiles" loading the vector tiles from a custom server or locally from a embedded MBTiles.
Android: https://play.google.com/store/apps/details?id=com.klokantech.osm2vectortiles
iOS: https://itunes.apple.com/us/app/osm2vectortiles/id1089255502
The trick is to point the style attribute in the API to your own JSON style file - which requests the vector tiles from your own server. An example:
See https://gist.github.com/klokan/3eee87899644f5d82b3946bf0cd1e176
See project http://www.openmaptiles.org/, where you can download ready to use vector tiles made from OpenStreetMap - or check the documentation of this project on how to generate your own customised vector tiles.
Hosting of the vector tiles itself is described at https://openmaptiles.org/docs/ or https://gis.stackexchange.com/questions/125037/self-hosting-mapbox-vector-tiles
You may need to host somewhere the assets (font glyphs + sprites) and the JSON style itself - or embed these directly into your mobile app.
If you want to rasterize the vector tiles with the same JSON style on a server - for a web-application compatible with old web clients (Leaflet, ...) or for static maps or print output with the same look&feel as you mobile app maps, you can check https://github.com/klokantech/tileserver-gl
You can use your own tiles. I tried 2 things. Generating my own Mapzen vector tiles (they use same format as Mapbox) And you can also use them for free. Here is their layer descriptions. This is quite work intensive. You need to have postgresql and load whole OSM PBF export into the database, then you run python server which requests data from this database and renders vector tiles. I think it is meant to render all the tiles in queue since it took couple of seconds per page to render visible tiles. Most of the time was spend in python after DB server was queried.
It's advantage is that you get nice tiles back. It has basically everything you need, but is much harder to customize. For example if you want to add specific style to cycle ways. You need to go deep into the code and change couple of query templates and a lot of other things.
Then I tried Tilemaker. This is just C++ program which reads OSM PBF dumps and lua config script (where you specify what tags to send into tile) and spits out mapbox tiles. It's advantage is that it is much easier to set up and customize and that all tiles are rendered at once. But it is harder to create nice tiles. (AKA load all the different highway tags are roads just of different kind. It is up to you to specify that but this already works in previously mentioned Mapzen and also Mapbox).
For example kind in Mapzen roads layer In mapzen this is already taken care of but in tilemaker it is up to you to write all the conditionals that get road type from different OSM tags into a layer. And it gets more complicated in landuse tags since kind is a:
combination of the landuse, leisure, natural, highway, aeroway, and amenity OSM tags, or urban area and park or protected land for Natural Earth areas.
Of course you can have completely different tags but it is nice to have one which tells you what landuse you are looking at.
You ned to know that Mapbox, mapzen your custom mapbox tiles all use same format, but each will have different tags. So the style you create for one probably won't work for the other.
For creating styles you can use Mapbox Studio (but is probably useless since it is in public beta currently and I'm not sure if you can specify own tiles there).
I used Mapbox codeflow, which is basically nodejs server with gulp script that reloads site with a map when style file changes. It also supports writing styles in toml, JSON5 and yml in addition to JSON. It also shows errors kinda nicely. (only line numbers are missing) Currently it support version 7 of styles but 8 is currently out. For getting line numbers of errors I used Mapbox GL style spec which can also update style to the new version.
You can also try Glug which is a different style language which compiles to Mapbox GL style. It is a little more compact.
For using tiles you can also create mbtiles with mb-util and use them.
If you have a running Tileserver GL, it is as easy as changing the following line from an example app from mapbox:
mapboxMap.setStyle(Style.MAPBOX_STREETS) {
// Map is set up and the style has loaded. Now you can add data or make other map adjustments.
}
to
mapboxMap.setStyle(Style.Builder().fromUri("https://maps.somedomain.com/styles/awesome_style/style.json")) {}

Making TileOverlays transparent

I'm currently working on a App that uses a custom TileSource to display data on Google Maps. I get those data in form of *.png images, and I'm using the URLTileProvider.
Everything is working well, but I'm now trying to make the TileLayer transparent, or at least, partly. The goal is, that the layer is visible but the underlying Google Maps still shines through. Somehow I'm stuck, as I do not know how to achieve this.
I did not find a way to fully implement a custom TileProvider, it seems one can only extend URLTileProvider
Serverside imagemanipulation is not possible, as the data is given
There are no options to make a TileOverlay transparent? (alpha, opacity, transparency)
I'd be very helpful if someone could hint me in the right direction, or tell me whether the Google Maps API V2 for Android really does not support this feature.
At this moment it is not possible to specify transparency for TileOverlay in android maps sdk v2.
Unfortunately setTransparency(float) method is available for GroundOverlay only.. The only way to do this - is to implement your own TileProvider and change png 'on-the-fly' to change alpha channel.
Can you make the tile images themselves transparent? The URLTileProvider can point to any images so if the image has alpha, it should work.
You can implement a TileProvider directly but you will have to take care of loading your own image data in that case. It seems like that would be more desirable if you want to generate tiles dynamically on the client.

Can we use our own map in android?

Can we use our own map(Like our house map) and then use GPS to show where we are in the map?
If it is possible then how to do it?
You can do anything you want, but if you are asking if there is an easy way to do this, no.
You would have to produce a scale drawing, then map the pixel space to the scale of the image, know what geopoints represented the corners of your map, then project that onto your scaled display image.
Some open source products use tiled images similar to google maps, but they use OSM data, I suppose if you were dedicated you could use that and turn your map into tiles but I would think for your purposes it would be easier to do this your self.
You might check the google code repository etc. and other open source venues and see if anyone has done anything similar to this.
Also the best accuracy you are going to get is about 2m, and certainly not indoors (if you got a signal at all)

Categories

Resources