I have a problem with drawing on my custom overlay when I zoom Google map to specific level.
I made my itemized overlay provided default marker, and aver wrote a draw method with path connecting overlay items. Next I added overlay items with Geo coordinates. WhenI run my application it works perfect showing all items with default marker and a line connecting those items. Then I zoom in/out and everything still fine but when I zoom very close my line disappears but markers still visible. If I zoom out line appears back to normal.
Dis problem exist only on actual devices, never on simulator.
Any ideas what it could be?
Thanks
The same happened to me on my Nexus 7. I solved the issue by changing android:targetSdkVersion="14" to android:targetSdkVersion="8" in AndroidManifest.
Update: You can use google maps api v2 (MapFragments)
Are you sure that both points (start and end point) of the line being drawn are visible in the screen after you zoom?
I've realized that on my device that when zooming, if the starting and ending coordinates for a rectangle are out of the screen, the rectangle will not be drwan, even if the center should be visible.
Regards.
Related
I am using Google map v2,everything works fine from viewing the map to applying polyline between markers.However there is one thing that I need to accomplish, it is to put arrow header inside the commonly used map marker.
The arrow must rotate or point to the direction of the next location and so on. here's the image looks like
map_marker
I have tried using only the arrow alone and it works fine with the use of .rotation(bearing) but my boss wants it inside the commonly used marker and only the arrow will move.They have a working sample but it works only in the browser using javascript.I haven't found samples or at least documentation about it on the internet only this similar question
How to display direction arrows in the map marker for google maps v2 android but unfortunately no one answered. I have also tried
.icon(BitmapDescriptorFactory.fromBitmap(getMarkerBitmapFromView(R.drawable.arrow_header)))
but the both the marker and arrow moves
I have done everything to accomplish this task and this would be my last resort just to inform my boss that just in case there is no way that it'll work on android. Thank you..
I have imported Osmdroid 4.3 into my application, but I have problem while tapping on displayed overlays. After I have moved over the map, I have to double tap overlay to display what I want, then, when I tap anotehr overlay, it just needs single tap (= the right way, app is programmed).
Question is, anyone faced same problem with newest osmdroid while taping on the objects on the map? Or is there anything changed from my previous version 3.0.8?
Thx
Edit:
Osmdroid 3.0.8 - I can pan map, go through the map, left, right, top, down. I have displayed POIs on the map. I can double to tap to zoom, pinchzoom to zoom-in or zoom-out. I click on POI, then I have all vailable details about POI displayed.
Osmdroid 4.3 - I can pan map, go through same as before. The only difference is, when I tap on POI item, map does nothing. Then, If I tap on the point again or I want to pan map doesn't matter. Both gestures are now the same and I see displayed POI details. When adding POIs to the map, I am using my custom class which extends OverlayItem. Why it needs double tab? Why is seems to me, that displayed OverlayItems are now "separated" from the map? Because first touch on them seems I have to "active them first", and with another touch (no matter what kind of touch is is) finish my work and display POI details.
I have done no change to the source code, only swapped the libraries. What am I doing wrong?
EDIT2:
I think I have found the change between osmdroid 3.0.8 and 4.3. In my App I am evaluating which POI was clicked by OnItemGestureListener and its method onItemSingleTap. In OnTouchEvent I am displaying POI details. In Osmdroid 3.0.8, while tap on POI, there was call hierarchy 1) onItemSingleTap 2)onTouchEvent. In osmdorid 4.3, their calls are switched, so 1)OnTouchEvent 2)OnItemSingleTap, so my first touch generates nothing.
I think I have found the change between osmdroid 3.0.8 and 4.3. In my App I am evaluating which POI was clicked by OnItemGestureListener and its method onItemSingleTap. In OnTouchEvent I am displaying POI details. In Osmdroid 3.0.8, while tap on POI, there was call hierarchy 1) onItemSingleTap 2)onTouchEvent. In osmdorid 4.3, their calls are switched, so 1)OnTouchEvent 2)OnItemSingleTap, so my first touch generates nothing.
Solution to this is: in onTouchEvent I get IGeoLocation from place I touch my finger. Then I look up the database and find all POIs with coordinates around my touch with distance lower then threshold. This threshold (e.g. +-0,010 lat and +-0,10 lon) must be set for each zoom differently. E.g. when having zoom 16, threshold is 0,001 (when click on 1 POI only, I don't want to see selection of distant points), when having zoom 12, I set threshold on 0,125, so my finger selects only some POIs which are together and not the whole map. So If you have ability in your app to touch multiple POIs, be aware of this change in Osmdroid 4.3.
I have one marker displayed and centered in my ItemizedOverlay in maps, currently I call setZoom(19).
But how can I control the zoom level? i.e. I want to zoom in as detailed as possible, but still showing the map in satellite mode clear.
I have noticed that if you zoom in to far everything just goes black. How can I zoom into the most detailed level without going to far?
Any help most appreciated...
Just use
setZoom(mapview.getMaxZoomLevel());
https://developers.google.com/maps/documentation/android/reference/com/google/android/maps/MapView
the solution is: look at the UiSettings in api v2 reference, there is the "setMaxZoomLevel" and "setMinZoomLevel".
Setup the max zoom level to the one that doesn't show a black screen (make some tests), then call the setZoom(mapview.getMaxZoomLevel());
Regards.
In the following screenshot you can see a white area (highlighted by red) appearing by default in every mapview. I know that the mapView in android has this default behavior but when the native Google Maps app is launched in the device, it doesnt show the white area. I would like to see that behavior. But i am out of options. Should there be any scroll listener on the map which will stop the panning over white areas. Any help is appreciable.
Thanks,
In the following screenshot you can see a white area (highlighted by red) appearing by default in every mapview.
It does not appear "by default in every mapview". This sample application, for example, does not have these areas, at least at reasonable zoom levels.
It is likely that your problem is purely at a zoom level of 1, due to the aspect ratio of the Mercator projection. It has been years since I bothered with a zoom level of 1.
but when the native Google Maps app is launched in the device, it doesnt show the white area
That is because the Google Maps application does not start out at a zoom level of 1. If, however, you pinch-to-zoom to get to its lowest zoom level, then pan around, you will see those white spaces above and below the map. Again, this is most likely due to the aspect ratio of the Mercator projection.
Should there be any scroll listener on the map which will stop the panning over white areas.
I doubt it.
I have faced some problems with the Android MapView API. I get OverlayItems from a database which I want to display in a MapView. If I'm displaying 100 Icons, I have no issues, but if it gets more - like 500 Items in one City - it first looks really bad, while second it slows down a lot. Unfortunately my goal is to display 10000 of them. I think one solution can be to register a listener to ZoomLevels to make them appear/dissapear, but I couldn't find that functionality. Second, I couldn't find a function to scale my Overlays with the Zoom of the Map.
Any Ideas are very welcome
There is a very strange behavior in ItemizedOverlay draw method. When you say: Draw line from (x,y) to (x1,y1) the draw method is called about 20-30-40 times - i don't know why. It is acceptable when you draw one line, but when you draw a thousands of lines,icons and so on...it is very very bad! To solve this problem you should create a cached overlay. This is overlay that catches the first draw, creates the object and then prevents the future draws that do the same draw.
A cluster is a dozen of icons behind one icon. For example if you have 1000 markers on the map, in a specific minimal zoom level you can not see each marker separately - it becomes a mess of icons and colors and so on. And instead of 100 markers that are very very close one by one you place a cluster marker. And on zoom in remove this cluster and create another clusters...do this until the markers became far enough away and you can seen them divided.
Check this: Cluster markers
Take the following approaches:
Create a cached overlay to prevent multiple drawing of same clusters;
Draw in thread;
Cluster your markers depending on zoom level and marker proximity.
Each time you draw in the overlay, check for sure is the current marker inside of the visible part of the screen. If it is not, do no draw it!
I had a similar problem with the icon size and zoom level in my application. What I ended up doing was having 2 sets of overlays containing the markers, one with a "zoomed in" icon and one with a "zoomed out" icon. Then just changed the overlay at a certain zoom level (using a zoom poller - On zoom event for google maps on android)