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.
Related
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.
I have a MapView (provided by Google Maps Android API v2) and what I'm trying to achieve should be simple enough, which is simply to draw a curved Polyline.
To be specific, I have an array of LatLngs and rather than having them joined at sharp angles, I want to have the route rounded off nicely, so that the line through the points follows a curve rather than straight lines and sharp angles.
Now, this used to be possible in the old Google Maps API by creating a custom Overlay, overriding draw(), and then manually drawing onto the map (e.g. with a custom Paint and Path with the desired settings).
Unfortunately it seems that in v2, Google have removed the Overlay class and moved to higher-level abstractions which no longer provide access to the draw() method. PolylineOptions is fairly basic and doesn't provide any option to draw a curved line.
Is there any way to override draw() or use other features of Google Maps API v2 in order to draw a curved Polyline?
There are a few questions already on SO which cover this issue, however there isn't really a satisfactory answer as yet:
Custom Overlays in Google Maps API v2
Overrinding draw() in customized MapView in Google Maps Android API v2
I'm sure there must be a way to do custom drawing on Google Maps v2, and whilst creating a custom overlay View and drawing onto that once the coordinates are synced up with the map is an option, it will quickly get extremely complicated when dealing with scaling and panning the map, so it's something I want to avoid if at all possible.
I have developed an abstract class CanvasTileProvider() where you just have to override the onDraw method, in order to perform your drawing as usual into a Canvas. A TileProjection object, which is passed into the onDraw method in addition, helps you to do the back and forth calculation between LatLng and points on the Canvas.
The only limitation is, that tiles are usually loaded only once. So this way of drawing into the map is suitable for shapes which do not frequently change. Thus it may not be suitable if your array of LatLng objects is continuously changing (e.g. because it shows the current movement of the device).
You can find the CanvasTileProvider class in the answer to this SO question
I am trying to show the position of a moving bus in google maps api v2 in an android application. I am able to mark the stops and draw routes using the markers and polylines. Now, I am trying to have an image(bus/Marker) that moves along the route that is there in the map. I am using GroundOverlay to achieve this, but I am not able to re draw the moving image/marker using GroundOverlay.
The problem I am facing is that, as I am drawing the map in the OnCreate function, the map, markers, routes and all the positions of the moving marker are displayed only once at the end of the oncreate function. I think I am going in the wrong direction. Is there a way to redraw only the moving marker? Is it possible to have a view on top of a map and draw on the view using projection? (is this possible in V2? If Yes, do we have some demo or sample available online?)
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.
I am using the google maps api for an android game that incorporates the players movement in the real world. I have figured out how to make markers indicating where something would be on the map, but I would like to keep a fixed map zoom level and have off-screen markers show up as arrows on the screen.
Anyone know of a way inside of the map API to do this without having to explicitly figuring out the angle to the object and rotating an arrow icon to point in that direction.
I don't have experience of the Google API, but from a simple point of view if you know the current location and the marker location couldn't you just use some simple vector maths to calculate the heading and, therefore, the arrow heading?
i.e.
MarkerPosition - CurrentPosition = TargetVector
TargetVector.normalize()