Use an animated Layout for a Google Map marker - android

I'm trying to use an animated Layout for a Google Maps Marker. However, in Google Documentation they only speak about drawables (Bitmaps). The difficulty is only one part of the Layout is rotating. It means, that I can't convert the Layout into a Bitmap and animate the whole Bitmap.
I read the following topic Using an xml Layout for a Google Map Marker for Android that is really similar to my problem. Then I also read the following topic GIF type animation for marker in google map api ANDROID
According to these topics, my code should be something like that (not sure it works!) :
googleMap.addMarker(new MarkerOptions().position(position)
.title("name")
.icon(BitmapDescriptorFactory.fromBitmap(myfunction())));
private final int ONE_SECONDS = 1000;
public Bitmap myfunction(){
// how to do there ?
}
However, I have some problems:
How to return a 'animated' Bitmap in the myfunction() ? I mean, how to return a different Bitmap each 100 ms ?
Is this solution a good way ? Because returning a different Bitmap each 100 ms may use a lot of memory for only one animation (and the animation could be not very fluid)...
Actually, maybe I should forget Google Maps ?
EDIT : I tried the solutions given by andrii-omelchenko however this way isn't good. It consumes so much resources for one animated marker !
I found an application doing what I want : ZENLY. Take a look there : https://youtu.be/0S-W8oSnzr0?t=18s
How to do the same marker ?
Thanks in advance for your help.

I have found a great solution : using TileOverlay : https://developers.google.com/android/reference/com/google/android/gms/maps/model/TileOverlay
So you have to add different forms such as circles and polygons and make their properties being dynamics.
It's consequently difficult just for obtaining this result !

Related

Make Google Maps API Default Marker Smaller

Im using Google Maps API in my app and placing a lot of markers on the map.
I need to make the size of the markers smaller, so they won't cover the whole country.
Note that i gotta use the default marker BitmapDescriptorFactory.defaultMarker
because i wrote an algo that defines the color of each marker group.
Thanks for the help in advance!
EDIT:
I know there is a way to resize the marker by setting a custom Marker image,
But i need to use the defualt marker,Therefore this topic is NOT duplicate
Follow these two steps down here:
Replace the Default Google Map Marker with the Bitmap icon as explained here
Then resize the particular Bitmap Icon in Activity as shown here.

android maps v2 api display metro lines overlay

I would like to display metro lines in an Android application. In fact I need to place markers on several stations, and others on coordinates (LatLng). So, I would like to have google maps of Paris (Paris only for now), and stations over it.
I've already tried GroundOverlay, but it works with small images only I think, I get a NullPointerException when using full size map. (1000 x 1000 px). The image I use is this one http://commons.wikimedia.org/wiki/File:Paris_Metro_map_complete.svg converted in .bmp.
Maybe another way could be to draw with lines & circle each stations, but it's a lot of work !
So my questions are :
1) I there a way to display metro & tram on android maps v2 api, just like the old maps.google.com (website, not the android maps v1 api)?
2) Is there a way to use an image like that as an overlay for maps ?
3) If not, have you another idea ? Add circles & lines is a good idea you think ?
Hope I'm clear...
Thanks a lot !
Audric
I would suggest using a TileOverlay.
You may use SVG file directly with svg-android library, drawing parts of it into Bitmap and then convert into byte[] of PNG file for use in TileProvider.
I also don't see why would you get NullPointerException on a 1000x1000 px image. That is only 4MB in memory. Try converting it into PNG instead of BMP.

Use own image as map and mark places using x,y coordinates in android

I need to use my own image as a map and place markers (or a small flag-image) dynamically on the map at different positions (x,y coordinates or l,t,r,b parameters) on the map based on certain criteria. I am having problems implementing it with 'ImageView', 'ImageMap' & 'Drawable' and have searched all questions on stackoverflow. Any help would be appreciated.
I did something similar to this for my very first app. Inside of my activity, I created a custom View class, where I overrode the onDraw method and drew my map image, flags, etc. This is the tutorial I used, I recommend you check it out: Anddev.org (you may not need to implement scrolling, but the rest of it should be relevant).
Alternatively, you can use the Google Maps API to display their map with Overlays but it doesn't sound like that's what you're looking to do.
You have to user Overlays for displaying images on a map. A very good tutorial is given in the official docs.

Merging overlays to display on MKMapView (iOS) or MapView (android)

I'm working on creating a mobile app which overlays images on top of a google map.
I have a large number of image overlays ('GroundOverlay' objects in KML-speak). I'm running into several issues (mainly performance) when the map is scrolled or zoomed
Having tried several options, I think my next approach will be to combine all the image overlays into one image beforehand, and then simply display that image as a single overlay on the map. Problem is, I'm not sure where to start.
Does anyone have any experience in combining overlay images?
I think there are two problems that need to be solved
1) Calculate the larger 'bounding box' that will contain the final image. I have the bounding box for each overlay ('LatLngBox' in KML-speak), and I think the final box can be calculated by simply examining the values of each LatLngBox and generating the final box based on the min/max values. Anyone have any insight as to whether this will work?
2) Merge all the overlay images into a single final image. I have no idea where to start here such here. Generating the actual image isn't the problem, but rather where to place each overlay (ie pixel level) so that the resulting image is accurate.
Any tips/hints would be greatly appreciated.
Thanks
the static overlay images can be combined and drawn. but the moving(regularly updated) overlay images would be an issue if you still want to combine them and post as one. the best option i believe would be to combine the static overlay resources and keep them in one set and other moving images drawn separately.
Managed to figure this out on my own.
Answer to (1): The technique I outlined in my question works perfectly
Answer to (2): You can convert between lat/lng and x/y pixels of an image as described here: Convert Lat/Longs to X/Y Co-ordinates

customize Google Maps API

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.

Categories

Resources