Is it possible to disable/enable multi-touch zoom in GoogleMap API 2? I like to implement it programatically disable or enable when it is necessary.
Thanks
Multi touch zooming is typically handled on a system level. You could have a toggle for turning zooming on/off, but not multitouch specifically (to my knowledge).
You should be able to toggle zooming in general with:
disableScrollWheelZoom();
And:
enableScrollWheelZoom();
You could perform a check for user agents (mobile) and disable it by default for those, then give the option to enable it.
To Disable the multituch zooming you can use this in the XML file:
map:uiZoomGestures="true"
you will have to add the map namespace in order to use it like this:
xmlns:map="http://schemas.android.com/apk/res-auto"
in your fragment xml code:
<fragment
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:uiZoomGestures="true"
same can be done in JAVA code:
map.getUiSettings().setZoomGesturesEnabled(false);
Related
After switching from maps v2 to v3 (due to Cloud-based Maps Styling) I get this result in Light Mode (as in the screenshot)
The map is as if covered by some black block (but this place is clickable -> maybe the phone is breaking something graphically)
If I change to Dark Mode on my phone it works fine
Map Fragment in Activity
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.libraries.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
map:mapId="#string/map_id"
android:layout_weight="1" />
Can something be done about it?
I known about use of RecycleView and CardView but i want to create Listview that can work like android L Recent App listview .
You can check from this link .
below is screen shot of android 5.0 recent app list.
You can use carousal libraries like
http://code.google.com/p/carousel-layout-android/ which allows creating vertical carausal.
Or atleast you can have idea from the source code.
As Mohammad Khatri said you can use
http://code.google.com/p/carousel-layout-android/
and change the activity_main.xml to
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="#android:color/darker_gray">
<!-- <com.touchmenotapps.carousel.simple.HorizontalCarouselLayout
android:id="#+id/carousel_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"/> -->
<com.touchmenotapps.carousel.simple.VerticalCarouselLayout
android:id="#+id/carousel_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
To complete previous answers (as I cannot comment),
In order to make http://code.google.com/p/carousel-layout-android/ work in vertical mode, you need 2 things :
In activity_main.xml, comment the HorizontalCarouselLayout and uncomment VerticalCarouselLayout
In MainActivity.java, comment the block dealing with HorizontalCarousel* and uncomment the one dealing with VerticalCarousel*
However, it doesn't work exactly like the recent apps display, since each swipe makes you move only one item in the list (there is no "fling" effect).
I just started programming my first Android app. However, even after thouroughfully following the Google Tutorial, including (!) getting a valid API key, the Google Maps doesn't load from the beginning (that means I can only see the grid).
The tiles are (weird?) only loaded after I use finger gestures (+- does not work) to adjust the zoom to a (random?) level. I don't have any idea on what could be the matter...once the first tile got loaded, the app works as expected.
I already worked through StackOverflow, the problem with everybody else was they were using MapView (V1).
I'm using
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
however...
I tried to write a test demo for Google Map V2 in Android Studio. I followed every step from Androidhive Google Map V2 or better I think I need.
I'm using the same layout_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="#+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
but I'm getting always the same rendering problem:
Rendering Problems
A <fragment> tag allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout...
I have absolutely no idea what's the problem. Did I forget something?
I just need to add Google services in the build.gradle like
compile 'com.google.android.gms:play-services:4.4.52'
I copied the manifest from the demo and changed the API Key.
The accepted answer is not wrong but it does not help.
As Dan wrote, Android Studio (also Version 1.0) will not display the map.
Maps needs an API key and dynamic processed code, maybe some day we will have that but so far not.
I've a 5 minute solution for those who want to see their app properly in layout preview:
To properly develop I still needed something else than a blank background.
I added overlays and buttons on top of the map, I really needed to see the map while placing elements over it.
The solution is simple:
1. Make a screenshot of your app with the map running (Power + Volume Down)
2. Download the screenshot and use an image editor to remove the top and bottom UI elements, so you will end up with only the map itself as an image.
3. Import that image into android studio drawables
4. create a new layout, name it dummy_mapviewfragment, put only a linearlayout and an imageview in
5. make the imageview "fill" the parent, and set "src" to the cropped image you just imported
6. back to your layout, add this into your Mapview Fragment xml :
tools:layout="#layout/dummy_mapviewfragment"/>
That's it, now you will have a non-interactive mapview fragment which displays a real map.
Your app will look like it looks on your mobile phone.
If you made errors in your image cropping you can "fix" it by setting the image scale to "centerCrop" so it will properly stretch out.
Update: You can get a screenshot without need to crop directly from within Androidstudio! Makes it a bit more convenient ;)
Rendering Problems
A tag <fragment> allows a layout file to dynamically include different layouts at runtime. At layout editing time the specific layout to be used is not known. You can choose which layout you would like previewed while editing the layout...
This is just the preview window telling you that it can't display a preview for the <Fragment.../> tag, because it doesn't know what kind of fragment you're going to put in it. You can safely ignore that message - your actual app will render the fragment fine when you run it (as long as you code it up correctly!).
Android Studio automatically offers a solution within the error description, which is adding the name of the fragment layout.
tools:layout="#layout/fragment_my"
Add a dummy layout "#android:layout/simple_gallery_item" as:
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="317dp"
android:layout_height="385dp"
android:id="#+id/map"
tools:context="com.example.XYZ.googlemaps.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"
tools:layout="#android:layout/simple_gallery_item"/>
I have problem in loading map with multiple marker in samsung epic.map will display after some time.pls give me the solution.
Thanks.
Google maps are dynamically loaded from internet. This is where the delay comes from. Check you internet connection.
If you are using map only for marker display purpose use lite map special feature by google map Lite Mode
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:name="com.google.android.gms.maps.MapFragment"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraZoom="13"
map:mapType="normal"
map:liteMode="true"/>
map:liteMode="true" it will make map in lite mode with some limitation
AND
For too many marker go with clustering of marker google link
clustering will increase readability of map
BEFORE CLUSTER
AFTER CLUSTER