How to make a TileOverlay cover the text of the covered map? - android

I have an app that use the old google map API and add a layer over the map to display a more precise map of my own over the map.
I'm trying to do this in the API v2 using the TileOverlay but the text of the google map are displayed over my tiles.
Here are 2 screenshots, one with the map, and one with the map with an overlay (just based on the API demo)
I tried to add a big Z-Index to the tiles without any results.
Is there any way to really cover the map with custom tiles ?

The reason why you keep seeing the labels, is that in google maps v2 the labels are rendered locally instead of being part of tile bitmaps. The benefit of this, is that you can rotate the map and still have the labels without rotation for easy reading.
Solution
The only solution I know so far is to disable the map base layer using setMapType(MAP_TYPE_NONE). However, this may have the undesireble effect of also disabling parts of the map that are not being covered by your overlay.
Regards.

Related

How to know if markers on the map touch each other

I am building an application which uses Google Maps. When displaying the map, I'm also adding markers. Is there a way to see if there are 2 markers that touch each other, meaning if a part of a marker is on top of another marker? My goal is to be able to find that out and then make them a single bigger marker instead of 2 different markers.
The answer should depend somehow on the marker's icon size and the current map zoom since if I zoom out, there's a bigger chance they might overlap.
There seem to be a library made by Google which clusters a set of markers together automatically when they are close to one another.
The library is the marker clustering utility and instruction can be found here:
https://developers.google.com/maps/documentation/android-api/utility/marker-clustering

Android Is it possible to change the appearance of the map in the google maps API

I have been searching in the documentation and throughout google. I would like to know if it is possible to place an image over the map the api comes from to use something else as a visual but with the maps gps functionality. Does anyone know if this is possible?
You can use two types of Overlays:
TileOverlays (reference)
A TileOverlay defines a set of images that are added on top of the base map tiles. You can also use tile overlays to add extra features to the map by providing transparent tile images. You need to provide the tiles for each zoom level that you want to support. If you have enough tiles at multiple zoom levels, you can supplement Google's map data for the entire map.
GroundOverlay (reference)
A ground overlay is an image that is fixed to a map. Unlike markers, ground overlays are oriented against the Earth's surface rather than the screen, so rotating, tilting or zooming the map will change the orientation of the image. Ground overlays are useful when you wish to fix a single image at one area on the map. If you want to add extensive imagery that covers a large portion of the map, you should consider a Tile overlay.

Google Maps V2: Does rotating the map change the orientation of TileOverlays?

Background: I want to draw several Polygons on a map (few thousand coordinates in all). This worked pretty fast on Google Maps V1 by Overlays. But Google Maps V2 seems to be ineligible for that.
First of all I tried to add polygons directly to the map by
googleMap.addPolygon(myPolygonOptions);
but this is not just unusable slow, it seems to be buggy too, because it always forgets some polygons.
Then I tried to draw the polygon on an invisible view placed above the map, by drawing paths. But the method
projection.toScreenLocation(geoCoordinate);
is a joke to its "toPixels" Google Maps V1 counterpart. Where Google Maps V1 takes 1 second, Google Maps V2 takes 21(!) seconds, so this is unusable too.
Then I thought about giving Overlays a try. Ground overlays seems to be what I'm looking for:
A ground overlay is an image that is fixed to a map. Unlike markers,
ground overlays are oriented against the Earth's surface rather than
the screen, so rotating, tilting or zooming the map will change the
orientation of the image. Ground overlays are useful when you wish to
fix a single image at one area on the map.
But then I read a comment in this posting that it is not performant too and doesn't even work well.
So the last hope are Tile Overlays. The question is: What happens with tile overlays when I rotate the map. Do they change their orientation too or will they stay oriented as loaded?
[UPDATE]
I tried GroundOverlays and they are pretty fast, even on old Smartphones, so I will choose this approach.
The tile will be rotated together with the map. The TileProvider will not get aware of the rotation at all. While drawing the tile is always oriented north up. You may have a look at the answer to this SO question for a very handy tile provider: Google Maps API v2 draw part of circle on MapFragment

Label at the top of the marker in google maps api v2

One more problem while switching to the maps api v2.
This is an ugly representation of what i want to achieve.
Edit1. There can be several markers, every marker with its own label. All markers and labels are shown simultaneously.
As you can see there is a label with some information at the top of the marker.
While using api v1 it can easily be done with drawing marker and label on Overlay.
How can I implement it using api v2?
The first idea is to render marker(red) and label(black) to one bitmap and set it as marker. But it will significantly increase marker area(red rectangle) and with this marker limitation gives me real headache with user to map interraction realisation.
The second idea is to use GroundOverlay, but at first glance, it is not designed for this purpose.
Edit2 Here is similar question, solution, like in the first idea, is to use both marker and label as single marker bitmap, created from view.
Have a look at a library I am working on:
googlemaps/android-maps-utils
You can use the BubbleIconFactory to achieve this:
IconGenerator factory = new IconGenerator(this);
Bitmap icon = factory.makeIcon("11:15 1.08.2013");
mMap.addMarker(new MarkerOptions().position(...).
icon(BitmapDescriptorFactory.fromBitmap(icon)));
This is much simpler to do on Android Maps v2. Please take a look at the official documentation here: https://developers.google.com/maps/documentation/android/marker
It is called Info Window. By default, an info window is displayed when a user taps on a marker and if the marker has a title set

Google Map API, with my own created Map figure

In android, is it possible that I would create my own Map figure, and then use this Map with the gps location from Google Map API
Example, I draw a map for my own house, then apply Google Map API to be able to make the location of each point in the map
Yes, I believe you can. A couple of options are as follows:
Draw your 'map figure' in an overlay - if the background is translucent, then you'll be able to see the Google map underneath.
Alternatively, use a dummy Google maps API key - in this case the MapView layer is rendered as a grey background but all the API calls appear to work. Again render your 'map figure' in the Overlay draw method.
In both cases, you'll have to ensure the map projection (scale, position, etc) match up with the coordinates of your 'map figure', especially if you scroll or zoom the map view.
It might be best going with the first option, initially, then you'll have a visual confirmation if you're code is correct.

Categories

Resources