Getting a SpannableString to my implementation InfoWindowAdapter - android

Google Maps V2. I have markers on a map that I have an associated SpannableString associated with. I want to display this spannableString in the popup window when the marker is clicked. I create an implementation of InfoWindowAdapter, but then I realize that all the data it receives is from MarkerOptions.. I can't attach a SpannableString to MarkerOptions.title() or MarkerOptions.snippit() because they only accept String. I can't extend MarkerOptions because it's final.
It appears I am sol.. however, there must be someway to do this I think. Is there a way to arbitrarily associated data with an object? I guess I could create a HashMap.. Seems hacky and obtuse..
All help appreciated. thank youuuu!

Using Map is the most often used workaround. See the discussion on gmaps-api-issues.
Alternatively you may try Android Maps Extensions, which adds Marker.setData(Object) and Object Marker.getData().

Related

SkMaps Remove SKPolylines

Currently I am removing SKPolylines by tracking their setIdentifier(int) numbers when I create them, and then when I delete them I apply a new polyline to the map with the same identifier that is transparent. I have two issues with this:
I assume there should be a way to do mapView.removePolyline(int identifier); or mapView.removeAllPolylines();
I also assume there should be a way to do mapView.getAllPolylines() that returns a List<SKPolyine> because that is possible with POI's and annotations. At the very least mapView.getNumPolylines(); that returns the number of polylines so that I can delete them all with my original method, without having to track how many I have put down.
My question is: Am I missing either functionality described in 1/2? If those functionalities do not exist then is there a better way than my current method?

Is it OK to show google map API without actually showing a map?

I would like to use google map API to get a map canvas to put objects on it, but not showing the map, by using the maptype NONE.
Am I allowed to do that in an Android app using v2 and distribute it?
This is what I want to do:
#Override
public void onMapReady(GoogleMap map) {
map.moveCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(-18.142, 178.431), 2));
// Other supported types include: MAP_TYPE_NORMAL,
// MAP_TYPE_TERRAIN, MAP_TYPE_HYBRID and MAP_TYPE_SATELLITE
map.setMapType(GoogleMap.MAP_TYPE_NONE);
}
I want to set map.setMapType(GoogleMap.MAP_TYPE_NONE); and then add various markers to the map, including my current position
Added a picture to show what I want to achieve.
As mentioned in Google documentation it's forbidden. More over - From what you are saying it seems that you want use gmaps capabilities to get data and calculations but actually display some thing else. I really don't think it's good idea. However - if the issue is making geo calculations, consider to use 3'rd party open source libs for this. For example http://www.gavaghan.org/blog/free-source-code/geodesy-library-vincentys-formula-java/

Get screenshot from yandex map kit

I have yandex.yandexmapkit.MapView. I want to create the screenshot from it.
How can I get screenshot from yandex map kit?
There are two ways.
First one is using the static Yandex map API (sometimes you aren't need to use complex Mapkit):
http://static-maps.yandex.ru/1.x/?lang=ru-RU&ll=32.810152,39.889847&size=450,450&z=10&l=map
The second way is drawing MapView into Bitmap and it's not difficult.
If you don't wanna use static Yandex map API, you can use MapView.getScreenshot() method.
Also, if this method returns null, well, in short, you should try adding xml attributeapp:movable="true" to your MapView.

Quadtree on android maps utils

I'm developing a android application with google maps v2 that draw polygons on the google maps. But now i have to identify a click on a certain polygon and popup a window.
I found this useful library on github
This library has the method containsLocation implemented. This method receives a LatLng (from click on the map) and a List (the polygon). This is fine but if i have 1 million polygon in the map i cant iterate all and test if a certain LatLng belongs to a certain Polygon. I remember that i can use a quadtree to get more performance and this library also implements a quadtree but it uses point. What is the best way of doing this? May i have to reimplement this quadtree for a quadtree of LatLng ? Or in each click i have to convert this click to a point and search on a point quadtree?
Regards
you cannot use a Point- Quadtree, you need an Object-Quadtree for your Polygons. An object quadree uses the bounding box of the polygon or any object for adding into the tree.
you dont need to consider latLong, use x,y with x= longitude, and y = Latitude.
Consider reading Hanan Sammet: Foundations of multidimensional data structures.
I think you need to implement a quadtree that stores the polygons, then query the tree to see which polygon (if any) contains the LatLng. If you search around I'm sure you can find a decent implementation.

GoogleMaps V2 android get marker icon

I'm currently implementing GoogleMapsV2 and try to port the old functionality I had in MapsV1. in V1, I was able to subclass an OverlayItem and save the icon i put inside. Now I have to create a MarkerOption based on a model object, add it to the GoogleMap to get a Marker back.
Because the Marker class is final, and GoogleMaps isn't providing a Method to get a handle on it (like a SQLiteCursorFactory), I feel unable to get the icon back I put inside.
If i keep the MarkerOptions object, I could get back a BitmapDescriptor which has only one (obfuscated) method aW() which is returning a b object.
I'm quite shure that the Bitmap must be somewhere inside this object because its drawn on the GoogleMap. What is the best way to get it back from the marker.
I'm currently mapping the Marker to my model upon creation inside a HashMap<Marker, ModelObj> but from there I have to re-create the icon everytime I want to access it. This feels simply wrong, and I'm wondering if there is a better method of accessing it.
I'm quite shure that the Bitmap must be somewhere inside this object because its drawn on the GoogleMap.
That's far from certain. The map is rendered by another process. So, while the Bitmap is in that process, it may not be in yours.
What is the best way to get it back from the marker.
You don't. That's a write-only API.
I'm currently mapping the Marker to my model upon creation inside a HashMap but from there I have to re-create the icon everytime I want to access it.
Then cache it yourself. Nowadays, Marker has getId(), which is probably better than using Marker itself as the key. But then either tuck your icon into ModelObj or have a separate bitmap cache. You will have to determine for yourself if the CPU vs. RAM trade-off warrants caching or regenerating the icon.

Categories

Resources