How to wrap a GoogleMap snippet in LinearLayout?

I tried this:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <fragment xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.SupportMapFragment" map:mapType="normal" /> </LinearLayout> 

But I have 2 errors:

  • <fragment xmlns:map="http://schemas.android.com/apk/res-auto" :

Unexpected xmlns namespace prefix found for tag fragment

2. map:mapType="normal" :

Unexpected map namespace prefix found for tag fragment

What am I doing wrong, and what does it look like to integrate more objects besides Google Map in my application ...

thnx!

CHANGE!

I tried this and it works!

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" map:mapType="normal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.SupportMapFragment" /> </LinearLayout> 

I can’t understand why .. also I can’t understand what map:mapType="normal" means map:mapType="normal" and xmlns:map="http://schemas.android.com/apk/res-auto" ... ??

+4
source share
2 answers

You tried:

 <LinearLayout xmlns:map="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" /> </LinearLayout> 

From http://developer.android.com/reference/com/google/android/gms/maps/SupportMapFragment.html it looks like two attributes are not needed.

i also replaced class with android:name .

To use the map attributes you need to add a namespace (I think you can add it to LinearLayout , more info at https://developers.google.com/maps/documentation/android/map#using_xml_attributes .

If the attributes do not work, I would probably just set the values ​​programmatically.

+7
source

For what I know, this is a known mistake that if you put a map on the layout, you cannot use the properties of the map prefix, and you must configure the map in your code.

+1
source

All Articles