I'v encountered a problem with Google Maps on Android. In my app I have a location-chooser where the user navigates to his desired location to save the exact street location. In order for the user to actually see what street he is no (and not just the general area) I need to mark the middle of the map clearly.
The problem is that the reticle (the little circle marking the center) from Google Maps usually won't show. It appears at the most 1 out of 10 times I open the map, probably less. This happens regardless if I add other overlays or if I just show the map as is. I am aware of ReticleDrawMode and have tried setting it to DRAW_RETICLE_OVER, but this does not seem to work (and it should be the default already).
Have I missed something here? I have searched for the problem and from what I have see the problem seems to be common, but I havn't seen a solution for actually forcing it to always show, only for hiding it.
If the reticle is broken, does anyone have a good suggestion for how to create a custom one? As I said the the user will navigate the map, so I can't just do a normal overlay on a fixed point of the map, and the map also does not take up the full screen so drawing something over it is a bit ugly (although I guess that will be my last resort).
And of course I found the answer just after I asked the question, or at least part of the answer.
I haven't found out how to get the reticle to work, but the easy workaround for this is to use the fact that different widgets can overlap each other in a RelativeLayout, whichever is declared last will simply lay above the other. So I ended up putting the MapView in a RelativeLayout and then simply placing a TextView in the center of the same layout. The TextView is now over the center of the map and can be used to mark the middle.
(Going to replace the TextView with something more appropriate later, but the concept stays the same).
Related
In my project, I have to show more than 3000 overlays on the map, each of them got a unique position, which causes the program too laggy.. I guess the problem would be my program has to update or refresh the shape of each overlay individually for the screen. My idea is to combine the 3000 overlays together into one, but I still don't really know how to make it out.
Could anybody give me any ideas?
You may use 'Polygon', A 'Polygon' is like a poly-line. A series of connected coordinates in an ordered sequence, It also form a closed loop and define a filled region.
For more information, please view Official Google Documentation for Combining and visualising multiple data sources: https://developers.google.com/maps/articles/combining-data
Also, Here's a related Stack overflow ticket, it might help you: Google map multiple overlay no cumulative opacity
Is there a way to check the visibility of an OverlayItem? So all I want to know is, if a overlay Item is shown on the map or already outside of the projection.
I'm afraid using the bounding box method of my original object which is represented by the overlay is a bit slow and since the MapView is doing this anyway...
(like hereHow can I determine if a geopoint is displayed in currently viewable area?)
Hopefully someone knows an answer.
Regards,
Tobias
I believe the best approach is the one you're already using (linking to). Perhaps you could look into ways to optimize the speed of it or reduce the amount of overlays you're using?
Does anyone know how to:
1) make the Google map not zoom-able? make it so it is at a fixed zoom size and the user cannot change it?
2) have the map API load a picture of my choosing and overlay the little blue dot of the user's current location over it?
Here is what I want to do, I'm want to have a custom picture of the world (that i have created in Photoshop or w/e, it will be .jpeg, .png, or whatever file format will work) the picture of the world will be 'artsy' and I just want the Google maps to overlay the little blue dot of where you are in the world. For example, if you are in New York, NY, you will see the picture of the world with the blue dot over what on the picture is New York.
Any help will be greatly appreciated, Thanks
You should be able to control the map as follows:
map = (MapView) findViewById(R.id.mapview);
map.setBuiltInZoomControls(false);
As for overlaying an image, you'll need to create an image layout file (in XML) and then inflate that over the top of the map. This tutorial shows you the basics of inflating a layout and adding it to an existing view:
http://www.mysamplecode.com/2011/10/android-dynamic-layout-using-xml-add.html
To position the inflated layout (your image), you will need to use LayoutParams (http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html) to set the position of the new view on to the map.
Hope that helps.
Regarding you second question: it sounds like you actually want to replace the Google Maps tiles by images you've created yourself. As far as I know, that's not possible with the Maps API. You can potentially hack something together by adding your own creation as overlay to the map, but that may not give your the results you're looking for, especially if you want the user to still be able to pan/drag the map around.
In stead, you might want to take a look at the osmdroid (Open Street Maps for Android) project. They do support loading in your own tiles via the ModularTileProviderArchitecture. It'll probably give you more freedom and flexibility, but might be overkill for what you're after.
I know that OSM is hip and cool, but the OP asked about Google maps — and the question is readily answered in the Google Maps API documentation (https://developers.google.com/maps/documentation/javascript/).
The Google Maps API has supported custom maps for years. I think you can edit their first "ImageMapType" (https://developers.google.com/maps/documentation/javascript/maptypes#CustomMapTypes) example to solve your problem.
In your case, you would set the "maxZoom" and "minZoom" fields to whatever zoom you want to create artwork for. Use the "mapOptions" dictionary to take away the zoom control. You'll need to cut your artwork into tiles, and replace their "getTileUrl" function with one that returns your tiled image.
I am trying to implement a map(not Google maps) like in the below image, which will have a hypothetical regions(not administrative) with different colors to indicate the population density. The regions will also be clickable and cliking on that will open a small info overlay.
For now I have the sliced images for each region with multiple colors (which color to be used is determined from an API request). But I am not exactly sure how can I implement this in Android? I've been doing some research for past couple of days but couldn't find anything satisfactory so far.
Things that I am having trouble to implement:
Put together all those images and form the map
How can I detect "tap/click" event in the regions
In one brief conversation with a guy, he mentioned something of "greyscale overlay-map, that is not visible to the user and which determines the right area by testing against the greyscale color index", frankly I didn't understand what he meant.
Here's what I am trying to achieve:
Any help or pointer to the right direction would be of great help.
Thanks for your time.
Check out www.trimaps.com, I think this is what you want. Sadly it isn't free.
I'm fairly new to the Android platform and was wondering if I could get some advice for my current head scratcher:
I'm making an app which in one view will need an image, which can be scrolled on one axis, with a load of selectable points over the top of it. Each point needs to be positionable on the x and y (unlikely to change once the app is running, but I'll need to fine tune the positions whilst I'm developing it).
I'd like to be able to let the user select each point and have a graphic drawn on the point the user has selected or just draw a graphic on one/more points without user intervention.
I though for the selectable points I could extend the checkbox with a custom image for the selected state - does that sounds right, or is there a better way of doing this? Is there any thing I can read up on doing this, I can't seem to find anything on the net about replacing the default images?
I was going to use the absolute layout, but see that it's been depreciated and I can't find anything to replace it.
Can anyone give me some code or advice on where to read up on what I need to do?
Thank you in advance
This really feels like something you should be doing with the Canvas and 2D graphics, rather than trying to twist the widget framework to fit.