Google Maps in a Webview for Android - java

I have a pair of questions about google maps for android. I decided to use a webview to display google maps due to the compatibility for the google maps api, so i'm having problems with really simple things (at least i think the are simple).
1) At the start of the application, my webview shows the map with a very low zoom. How can i set a higher zoom from the beginning? There are +/- buttons, but they are pretty uncomfortable.
2) How can i put a mark on the map? With the api, i have just to use the
google.maps.Marker
, but i don't know ho to use it with a webview.
I think that both the problems can be solved using javascript, but i'm new and i really don't know how to solve them. Thank you very much.

For the marker, you could create a javascript function to add a marker, and then on the WebView load a url like javascript:addAMarker("AddItHere");. I don't get what you mean the buttons are uncomfortable for the +/-.

Related

Android: Yahoo Weather App Horizontal Scroll-view Effect?

I would like to know what the Android implementation is of this type of scrolling that you see in the Yahoo Weather App. Here is a video example:
http://www.youtube.com/watch?v=a-q_yetkpik
Any examples or ideas on how to implement this would sincerely help this poor lost soul!
Thank you
use that library https://github.com/xgc1986/ParallaxPagerLibrary, it's very easy to use, and it worked for me
demo
You should separate two different things here:
The horizontal scrolling
As you swipe your way through the viewpager, the background moves slower than the content does.
This effect can be achieved with the ParallaxPagerLibrary
The vertical scrolling
As you swipe up, the background image blurs away, making the "swiped up" content more visible to the user. This post explains it all and also provides a library.
But if you want it even better, someone wrote a simple "clone" of this weather app https://github.com/MoshDev/LikeYahooWeather
They customized ViewPager, the widget is called WeatherViewPager that it's unfortunately unavailable, looks like a ViewPager with a sort of parallax
You may take a look at https://play.google.com/store/apps/details?id=com.desarrollodroide.repos
it's a collection of usable opensource libraries
e.g. Utils->Paralloid or Utils->ParallaxScroll

How to handle Google Map v2 Marker's Long click event in Android?

I'm developing an android application in which I've used Google Map v2 API.
I've placed one marker on the map, now I want to set its "OnLongClickListener".
As I can see from Eclipse there are only two listeners available for marker:
googleMap.setOnMarkerClickListener(listener);
googleMap.setOnMarkerDragListener(listener);
Could anybody show me any easy way to handle marker's LongClick event??
I've gone through two solutions here:
Setting a LongClickListener on a map Marker
How to detect long click on GoogleMap marker
as both of the solutions you posted have shown - there is no long click event on markers in the maps api. the first link you posted had a solution that might be able to suit your needs but isn't perfect by any means
i would suggest going here to the gmaps issues page and browsing through the feature requests and adding one if it does not exist

Possible implementation of game screen concept for an android game

I want to develop an android app, but I'm still not that great at using xml or the eclipse wysiwyg editor to make scalable and robust interfaces!
Below is a quick concept I drew up on word of what my main game screen will consist of:
I'm currently thinking a vertical linear frame first, with a frame that doesn't change for my important stats etc., then a frame in the middle which is switched by the buttons, but I'm stuck on how to implement this.
For the centre button screen, the map screen, I am hoping to add an image of a map which can be moved around, and somehow attach invisible button objects to points in this picture, maybe with an array of squares or something?
I understand this is a pretty open question and might be difficult to answer, but if you think you can help in anyway please do.
Thanks!
There is a log of possibilities, but you can use a LinearLayout with android:orientation="vertical" and include your stats in top. For the changing screens with buttons you can use a FragmentTabHost and create different Fragment for each of your views.
Check this example with a implementation.
Regarding the map, I think the easiest option is to use Google Maps Android API v2. Here is a example to use the maps v2 and a example of how to add markers to the map.

Java android ImageView with zoom

I have been searching for a view that can handle this. What i want is to allow the users to zoom in/out of an image.
Right now i can not find any pre-built solutions for this except the WebView. One could argue that Google should actually offer this without having to resort to the WebView (That one limits the layout possibilities).
I would like to have the same built-in functionality like for iPhones/iPads.
So question is, what user-built views are there out that could handle pinch-zoom in/out of an image?
I have tested 2 different custom made solutions but neither worked as expected. One managed to re-size, but only in one direction at a time (either horizontally or vertically) and the other did not even work.
Update: It should be possible to use the solution with Android 2.3+. (Majority of the users are in that range)
I've found one very interesting few days ago. I think it's the best one I've seen. You can zoom with a double tap, pinch, has acceleration with movement, etc.
Take a look here.
There are several Android view libraries that can handle what you are looking for.
Check out these
https://github.com/chrisbanes/PhotoView
http://code.google.com/p/android-pinch/
https://github.com/jasonpolites/gesture-imageview
I achieved good results with this library: http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/
It is not a total drop in replacement for imageview but it also works in a Viewpager where the Viewpager handles horizontal Swiping for page changes.
Starting with Android 3.0 (API Level 11) you can zoom every view using setScaleX(), setScaleY(), setPivotX(), setPivotY() etc., or just using setMatrix().

Help needed with multiple itemized overlays on a mapview

I am looking for some help....
Firstly I have a database server side with a numerous amount of locations(longs +lats)
Now there are upto a 1000 for one city alone. At the moment, my android device all the information at once. I then create 1000 itemized overlays and add them to the map view.
This in turn makes my emulator and phone run slow.
One idea I had was to zoom in on a location and then download and place a subset of the overlays on the map view.
Trouble I have with this
1. When I scroll on the map I don't know what event to register a listener to.
2. When the user zooms out I will still create the large number of itemised overlays.
My question to you guys is,
How could I overcome these problems? Or how would you go about doing this?
The solution Would be something similar to how google maps works. U c a not so detailed map when u zoom out, but when u zoom in it shows you a detailed map that reloads as you move around
I then create 1000 itemized overlays and add them to the map view.
Ummmm... please tell me that this is a typo, and you meant "1000 OverlayItems", not "1000 ItemizedOverlays".
1000 OverlayItems might be bad enough -- ItemizedOverlay isn't really designed for that many points.
When I scroll on the map I don't know what event to register a listener to.
I don't think there is a straightforward solution here. I think others have kinda reverse-engineered the touch events and are listening on those. See Android Maps get Scroll Event for more.
When the user zooms out I will still create the large number of itemised overlays.
Use a prioritization scheme. What you see with Google Maps is that only the top N items are shown, where "top" is based on some sort of priority mechanism.

Categories