I'm writing an app which allows the user to change the colour of countries on the world map by tapping on them. At the moment I'm struggling to find the apt way to store and display the map, allowing it to be partly coloured at the same time.
On of the solutions I had in mind was to use an SVG and a third-party library, but as far as I know none of them provides the necessary callback to modify the image once it's drawn.
I am merely at the beginning of understanding of what Canvas is, but even now it is clear to me that drawing such a complex object as a world map on Canvas is way too hard. It will probably take ages to load as well.
I have not implemented any of the mentioned things yet. I assume there is a better way that most developers use, so I'd like to find out what it is.
After more than a year I have finally found a working solution.
Google Map's Android API Utils provide a great means of applying various overlays to Google Map views and fragments as well as changing their individual components.
I went with a geojson layer upon the map and updated the fill colour of certain features.
Related
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.
Good Morning,
Part of my question uses the word OpenStreetMap instead of osmdroid because part of what I need is a map visual reference/preference for users of my app but I need a grid reference of a map not just lat/long. I believe it was a link from SO that lead me to this: http://dhost.info/usngweb/USNG_OL.html. This is very much what I had in mind for the visual side of my app. The grid is right there. In other words part of what I need has already been created.
The author of the grid in above link uses JavaScript to create the grid of the Military Grid Reference System, which I am familiar with from IBM's tutorial - and zip j-coordconvert.
My question:
1.) In the above link there are radio buttons to switch from the type of map and also the meter zoom. Would it be good advice to use an Action Bar to allow user's to adjust these preference's? Has this also already been done?
2.) If the advice is to use an Action Bar - once user has selected a preference he/she will go to another choice with the original selection seldom changing - would I build that Action Bar up so that I have http interface with the above OpenStreetMap? If your advice was not to re-invent the wheel and use http to reference the already created grid, I would want to grab user's preference is there a code snippet to get the selected preference from http into Sqllite?
This last question my end up being the biggest part of this set off questions - getting the zoom level from http into Sqllite.
Of note:
-Will, at first only be needing one rather big city in U.S. so can cut tiles needed down
-Need rather quick solution on map side as other parts of app will take longer, so can build up my own map grid over time
-Could cut out the selecting of different map types but not grid zoom
-Using latest version of Android Studio
-Familiar with retrofit
-Referencing Busy Coder's Guide 6.6
-Would prefer to stay in Java rather than JavaScript
-Will be targeting newer phones/Android version above 3
I know this is a lot to ask but I am rather new to Android and my head is swimming with the amount of information out there (a good thing).
Thanks,
Terry
There is no "preference from map source to sqlite".
If you need to provide a TOC (that selector on top right) you need to build up your UI and do the logic for enabling/changing layers (what you see on the map).
You can use Google Maps API (v2) to have the map (just set the map type to NONE and add openstreetmap as a TileProvider, there's a lot of examples, just google it).
For the grid, a brief look at the page source code seems that the grid is created by javascript and is not a webservice that provides tiles (isn't it?). If so you have to create your logic that creates the tiles given the coordinates, this is a bit long to do, but you could look at some code online, for example Google I/O app has something with SVG files:
https://github.com/google/iosched/blob/master/android%2Fsrc%2Fmain%2Fjava%2Fcom%2Fgoogle%2Fsamples%2Fapps%2Fiosched%2Fui%2FSVGTileProvider.java
About preferences on enabled layers you can use SharedPreferences.
I'm trying to create an app that will tell a person what zone of a building they are in. I'm using bluetooth dongles to get an approximate location, as oppose to exact location, and show the user on a map whereabouts they are. I would like it just to highlight the zone they are in, instead of a specific location.
I can get my hands on a floor plan of the building I am using so I'm just wondering if there is an easy way to incorporate this into some kind of map with an existing API? I found a question here which states that they just use an overlay on the image to show a marker of where the person is. Would this be a bit easier?
This is for my final year project so I would like to have some sort of flashy map if possible but I'm not sure where to start looking or if it's possible.
I also found this question which gives a great variety of apps that implement and indoor map, but I don't think I can just take this small piece of functionality that I need out of them as they seem to be complete apps.
Any information would be a great help. Anyone with experience in this sort of thing please share your knowledge :)
It doesn't sound like it'd be too complicated to just write your own custom view for this. Draw the map image to the canvas. Then for the zone the user is in, draw another 'highlight' graphic on top of the map that you just drew.
If you're not sure how to do this, there's a rather basic guide on how to create your own drawable widgets which should point you in the right direction. There are plenty of examples on drawing images to the canvas, eg this one.
So, my question is somewhat of an odd request I think. I was an intermediate java programmer making android apps a couple years ago, but I quit for other things. Now I'm back with a new and (I think) somewhat bold idea and I need help.
I'm wanting to know if it is possible to utilize the google maps api to act as a base for another map that I layer over the top. Think of it as I'm changing the way the map looks and that's about it.
I'm wanting to create a mobile app that has a map with a new/different look than what the base and satellite views have for a set small area of the city. Think of it as something like taking any old image and slapping it over the top of the google map and still being able to navigate with it (obviously if it was a random picture you wouldn't be able to see where it was taking you, but in theory you could essentially create a new map).
Is this possible in both java and obj c?
As far ask I know, you can't add your own tile layer to the Google Maps API for Android. However, you can use osmdroid and add your own tiles. You could also use mapsforge for Android. It comes with it's own tool for creating custom map tiles.
I have a couple of images on available to my program. They are parts of jigsaw puzzle (with rectangular pieces though). I wanted the look and feel similar to that of google maps in android.
One way I could implement was to create a set of ImageViews and keep recycling them, as the user pans the image in any direction. However, to me that appears like a brute force method. Is there any alternative approach to implement such kind of application?
Or rather how is google maps implemented? A set of Imageviews ?
I think for your case the OpenGL route might be the best choice. You can get started with the GLSurfaceView.
Using set of images and recycling them is a valid method. But you can enhance it by adding some redundant ones to keep close to view area images preloaded.