I noticed that the position of the builtInZoomControls in WebView (bottom, horizontal right) is not consistent with the default position in the MapView (bottom, horizontal center).
1) Why is that not consistent? (Probably a question to be asked to Google)
2) Is there a way to horizontal center the builtInZoomControls of the WebView without applying custom Zoom controls? Or is that the only way?
From my experience with the Android UI, here's what i've noticed
When using a Maps activity, there is really no reason to align to the right, you are looking at a map, ie. a 2D surface that can be scrolled at will.
When browsing a website, most content starts at the left and runs right.
So, placing the control in the lower right while browsing the web makes a lot of sense, to keep it out of the way, when using maps (where the zoom control is more important), the control should be more prominent, thus in the center, where it still does not get in the way here.
Upon first reading your post, I was going to suggest using a custom zoom control, but I realize that you have thought about this already. If having centered controls is essential to your application, a custom control seems to be the route I'd take.
When viewing maps in a WebView you are actually using the Browser app to view the Map Tiles. In order to change the zoom controls when in Web View you would have to manipulate the zoom controls of the browser being used to view the Map Tiles.
You should try manipulating the WebView zoom controls and not the MapView zoom controls.
Related
I am trying to make an indoor map of a hospital , when i click on certain buildings it would open their respective indoor maps and when i select a certain area of their respective floor it would show me further details.How can I achieve this?
Any suggestions would be appreciated.
P.S I have tried using image view but i can't get the image to scroll freely like a real map or a webview (pinch zoom in/zoom out ,rotation etc).
As you wanted your "floor" to have the behavior of a map you should have look for custom map implementations.
Then you may have found that you can use your own Tile Overlay using a Custom Map Tile Provider as described in Using custom map tiles with Google Map API V2 for Android?
Or if you don't want to use Google, you can look at Open Street Map Android SDK
Ether way you are still responsible for the graphical assets of tile layers. As well as any UI/UX leading to the custom map view.
Alternatively there are third-party libraries for 'deep zoom' of an image which may provide the expected touch behavior like: https://github.com/davemorrissey/subsampling-scale-image-view
You can have rooms as scolling views, with a background view image and buttons where you want to click. Clicking the buttons opens a popup with an image. You can also place transparent buttons on the buildings to have a natural feeling of click to open.
From your question it seems that you don't want to use web view, but you can code a regular html page/web app and use a web view to display it. That way, you only have a screen with a web view to deal with.
Then the possibilities are endless and fun and shifts in the web domain!
For an app I'm working on the user needs to be able to zoom in and out using pinch gestures, but only within a certain boundary.
There are multiple "levels" on which users can see the map and there should be a settable zoom boundary for each of these.
We got this working partially by resetting the camera back to the limit if pinching has brought it outside of it's boundaries, but the user shouldn't be able to pinch out/in of the boundaries at all.
Here's a video of how it's working now:
https://www.youtube.com/watch?v=WfAle_M-i0k
And how it should work is that once the camera is at the zoomlevel-limit, zooming out further shouldn't be possible.
This is important because we'll be drawing a lot of objects on the screen and the app crashes when it's zoomed out too far.
We're using the default pinch-zoom that comes with
mMap.getUiSettings().setZoomGesturesEnabled(true);
Is there a way to disable further zooming in/out when the boundary has been reached?
I don't see any other way of doing this that implementing zoom controls by yourself, i.e. setting
mMap.getUiSettings().setZoomGesturesEnabled(false);
and adding buttons on top of your map with actions with zoomBy inside (with respect to your zoom boundaries kept somewhere).
You may also check lite mode.
I'm looking at moving default zoom controls of osmdroid to a different position. Is it possible to do this? If so, can anyone point me how?
I tried digging deep, through much of stackoverflow but no result. Or should I go with customizing by creating a custom zoom controls again for my app?
My intention is to relocate the already available zoom controls to a different place on screen.
You cannot relocate the MapView's integrated zoom control using the OSMDroid API.
The only way to do that without modifying the library's source code is to implement a FrameLayout over your MapView and that will include the controls you wish, where you wish. This also allows you to customize them (by showing a slider for example).
Once this done, you should ensure that MapView.setBuiltInZoomControls() is set to false.
After working with WebView for a while, and then moving back to standard Views, zooming and scrolling seems quite complicated. Are there any ways of using the same zoom and scrollcontrols for any View group, (builtInZoomControls, Horizontal and Vertical Scrollbar, Double tap to zoom out and pinch zooming) or are there any workarounds like an SDK or jar. file that will make this possible?
zooming and scrolling seems quite complicated
Scrolling is a matter of using widgets that know how to scroll (e.g., ListView) or wrapping other widgets and containers in a ScrollView or HorizontalScrollView.
Zooming is not normally done except in fairly targeted circumstances (e.g., zooming an image, zooming a map).
Are there any ways of using the same zoom and scrollcontrols for any View group
For "scrollcontrols", see above.
There are a few open source classes floating around for zooming an image. Zooming a map is built into MapView.
I am working on an application that can read pdf documents and I am trying to implement zooming and panning on a pdf page.
The page is loaded as a bitmap and displayed in an ImageView. There are also some other functionalities already implemented such as navigating the pages in a document with a bottom custom navigation bar that can be scrolled.
Also, the bottom bar appears when the user taps on the page and disappears with the next tap and when flinging, users should be able to navigate to next/previous page in the document.
All functionality such as the scroll, tap and fling is handled by implementing OnGestureListener in the reader activity and I am trying to do the zoom and pan with an OnTouchListener implementation that is set on the ImageView containing the page.
The code seems to work, however it appears that some of the other events, especially the scroll, are interfering with it which makes it slow.
My question is if there is a better way to go about reconciling everything, since the OnGestureListener is used for the GestureDetector's handling of onFling, onTapUp and onScroll, but I can't find a good way to add the zoom/pan code in one of the methods supported by this.
So, if anyone has some experience on handling all these events for one view or some good suggestions/tutorials on this, I would very much appreciate it.
I'm not sure what you mean by 'some other events such as the scroll make it slow', could you elaborate?
You should be able to perform zoom and pan using onTouch fairly trivially, without scrolling being an issue if you choose to use Canvas. Full implementation code can be found at Touch and drag image in android for scrolling, and http://www.zdnet.com/blog/burnette/how-to-use-multi-touch-in-android-2-part-6-implementing-the-pinch-zoom-gesture/1847 for zooming.
It's generally not common to see advanced interactive features applied solely on an ImageView, but that doesn't mean people haven't done it (see How can I get zoom functionality for images? for zoom examples including support for multi-touch or Adding Fling Gesture to an image view - Android ).
Regardless of which way you do it, you'll probably want a GestureDetector in your onTouch function. You should be able to just cut and splice together sections of the tutorials I've linked to in order to get full gesture support + zoom/pan. However, if I were doing it, I would probably just use onTouch with Canvas (since Canvas will give better performance) and use the core MotionEvents such as DOWN MOVE UP for greater control, or if I was feeling lazy, use a GestureDetector for trickier bits like flinging.