I have a map based Android program, that is working nicely, I have it opening an alert dialog when an overlay is clicked...
I start the app, and see my overlays, and all is fine, until I select an overlay. When I select an overlay, my alert dialog appears as expected, but when I close it, suddenly all the annotations suddenly shift down and right a little bit, and then stay shifted from that point on.
It almost seems like the bounds of the overlay suddenly got resent from being set on the middle of the image I am using for the overlay, the top right corner of the image. Is this a KNOWN android issue? I don't have anything in my code explicitely playing with the bounds of the image after I initially set it to the be configured to the center yet this seems to be happening... any ideas?
I figured it out, I was passing the drawable that was my overlay to the AlertDialog to be used as its ICON... apparently the AlertDialog code reset the bounds on my Drawable from being Center Bottom as I had it set up, to top left, and so when I dismissed the dialog and the map redrew all the overlays shifted so that there location was upper right of the Overlay Image and not the center of it from that point forward.
It would have been nice if the API documentation mentioned this.
Related
I have an app that draws an overlay. However, the Facebook chat heads are always drawn over the top of my overlay. I have tried re-drawing my overlay every second (obviously I wouldn't do this in the final app) but the chat head just stays on top, there isn't even any flicker giving a clue that it's being re-drawn. I would expect the last overlay drawn to win and end up on top so unless Facebook is redrawing at a ridiculous rate what are they doing? Any ideas? Thanks.
I fixed it by setting the type in the layout params to TYPE_APPLICATION_OVERLAY for Oreo and later and to TYPE_SYSTEM_ALERT for pre-Oreo.
Building custom overlay specifically circle with radius(colored) in Android MapBox GL. It allows to change radius dynamically using seekbar.
I'm trying to build some custom markers and I used SimpleCircleView but Im having problem trying to display it in MapBox GL android, and it created lots of bugs.
The map touch event is unresponsive once my CircleOverlay is displayed in map
The marker doesnt stay in its coordinates once i zoom-in , zoom-out.
Updating markers doesnt work, So I have to remove then add again the marker.
The color does not match the color that I set in marker.
I'll limit my posting on code, because this repo is mine and to keep the problem understandable.
In building custom overlay I have to make these classes:
CircleMarkerView.java - The Custom Marker View
[CircleMarkerViewOptions.java] (https://github.com/spurdow/SimpleCircleView/blob/master/app/src/main/java/com/spurdow/circleviewtest/CircleMarkerViewOptions.java) - This is to be used with CircleMarkerView
SimpleCircleView.java - This is my custom view for dynamic circle changing its radius etc.
MainActivityMapBox - This is where to put it all
This is an example of the code in the repo.
Does anybody have any idea how to do this simply?
Or
Is there another way of building an overlay dynamically?
Or
Is it possible to create a circle bitmap dynamically and convert it to icon when seekbar's progress is changing?
1. The map touch event is unresponsive once my CircleOverlay is displayed in map
This is an issue we plan to address by next release, you can follow progress on this here.
2. The marker doesnt stay in its coordinates once i zoom-in , zoom-out.
The could be because you aren't anchoring the marker icon correctly using .setAnchor() or your icon has padding around it. For a circle, you'll want to anchor centered (using 0.5f). A bug was introduced right before the previous stable release that causes anchoring not to work correctly. If this is an issue, use the 4.2.0-SNAPSHOT.
3. Updating markers doesnt work, So I have to remove then add again the marker.
Could you elaborate on this issue? You might be using
Marker marker = mapboxMap.addMarker(new MarkerViewOptions()...
When you should be using:
MarkerView marker = mapboxMap.addMarker(new MarkerViewOptions()...
Which will give you more options to update markers.
4. The color does not match the color that I set in marker.
Could you clarify what you mean by this?
It sounds like you are wanting to do what this example does in the testapp? I would follow along with the code found there.
Hello,
can anybody give me solution for how to change place of current location default icon (as rounded in above image right corner) from right corner to left corner.?
thanks.
According to this thread, you can reposition the items by using GoogleMap.setPadding(left, top, right, bottom).
Here is the actual statement:
We added GoogleMap.setPadding(left, top, right, bottom), which allows you to indicate parts of the map that may be obscured by other views. Setting padding re-positions the standard map controls, and camera updates will use the padded region.
https://developers.google.com/maps/documentation/android/map#map_padding
If you want to do that, you should hide the default my location button and add your own Button to the layout on the left side, handling onClick to call animateCamera. You cannot reuse default button's drawables this way.
Note: this is not a good idea, because other apps will have this button in the right corner in other apps using maps and may expect it to be there in your app.
I am developing an application which makes use of google map. I have some overlays added to show location of certain places. These overlay items can tap to get more information. I followed the link How to show a balloon above a marker in a MapActivity? Isn't there a widget? to achieve. Besides, I need to show some animation around the overlay item to show that it is being selected.
I have one idea which is to draw some circles(just stroke, without fill) simultaneously one after another. Start from small circle with thicker stroke to big circle with thinner stroke. When the second circle is drawn, the first circle should disappear. It would be like circle gradually growing (ripple effect) . Of course, it would disappear and start the process over again.
I am having trouble with drawing circles on the mapview. Is it just another overlay or something else? I would be grateful if anyone could show me similar thread or recommendation. Any suggestion are welcome too.
I have balloon popups showing in Android MapView when a user tap:s on specific points on the map. Depending on where the user taps the balloon does not always fit insize the MapView. I solve this now by using MapController.animateTo to always have the tapped point in center. However, this is not the way I prefer it to be. I would like to animate the MapView only so much that the balloon layout fits inside MapView.
Any tips on how this can be solved?
One way to fit the balloon overlay is to override the dispatchDraw method, check the bounds of the display using getMeasuredWidth and getMeasuredHeight, and, draw the balloon such that it fits within the display area.
I am not sure if you have seen the Android MapView Balloons project on github. I have been using this code for a while and it is excellent, may be you can find some pointers to your problem from there.
Hope this helps.