Reputation: 4565
There is Android Google Maps v2 inside Scrollview It works on many devices but shows gray tiles on some devices API KEY is Correct,
To use Google Maps V2 inside Scrollview should to use custom class extends SupportMapFragment, Like This :
public class WorkaroundMapFragment extends SupportMapFragment {
private OnTouchListener mListener;
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle savedInstance) {
View layout = super.onCreateView(layoutInflater, viewGroup, savedInstance);
TouchableWrapper frameLayout = new TouchableWrapper(getActivity());
frameLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
((ViewGroup) layout).addView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return layout;
}
public void setListener(OnTouchListener listener) {
mListener = listener;
}
public interface OnTouchListener {
public abstract void onTouch();
}
public class TouchableWrapper extends FrameLayout {
public TouchableWrapper(Context context) {
super(context);
}
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mListener.onTouch();
break;
case MotionEvent.ACTION_UP:
mListener.onTouch();
break;
}
return super.dispatchTouchEvent(event);
}
}
}
And also set :
((WorkaroundMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).setListener(new WorkaroundMapFragment.OnTouchListener() {
@Override
public void onTouch() {
mScrollViewDa.requestDisallowInterceptTouchEvent(true);
}
});
The image bellow taken by users, Android version : 4.2.2 , Device : Samsung Grand 2
App tested on : Samsung Galaxy Tab 2 10.1" : 4.0.3 And Asus Fonepad 7" Tablet : 5.0.1 And Works well
android:minSdkVersion="10"
Upvotes: 6
Views: 308
Reputation:
I am not entirely sure if this will answer your question, but it is worth investigating.
From your question and the comments, it appears to be a user in Iran on a particular device that is receiving the grayed out maps. As I am not sure of the user's exact location, I have done some research on the accessibility of Google Maps in Iran and surrounding areas.
It is possible this user is trying to locate maps that are intentionally grayed out.
Satellite map images with missing or unclear data
Not all things are shown on Google Maps.
Blurred Out: 51 Things You Aren't Allowed to See on Google Maps
There were problems a couple of years ago with consumers using Google in Iran and Iran wanting to create an Islamic Earth Map.
Iran plans 'Islamic Google Earth'
However, this seems to have been resolved with people having access to Google maps in that area.
This is also a map of the US military bases near Iran. Of which there are many and are at least likely to be blurred, if not grayed out.
American Military Bases Near Iran
Also in neighbouring Iraq, there are issues with outdated aerial footage.
when Iraq will get new satellite imagery update
Also, with Iran's Internet Censorship policy and use of 'Smart Filtering'
Iran expands 'smart' Internet censorship I am not sure if this would affect the access to Google Maps in some areas.
I would suggest asking for the users specific location, or asking if the maps appear in some places and not others.
Hope this helps.
Edit
The Galaxy Grand Duos (GT-I9082) has only recently been updated to 4.2.2.
There are multiple issues with the jelly bean update for the Samsung Grand 2
If your user has recently upgraded his phone, it may be worthwhile checking into this.
Although the following link isn't specific to google maps, it is still useful.
Samsung Galaxy Grand: Slow Performance after JB 4.2.2 upgrade.
Beyond investigating the particular device and any issues I've mentioned previously, there is not much else I can offer you at this stage.
Upvotes: 1
Reputation: 138
For a similar problem I have taken a different approach.
Yes, you're right that you cannot have a map directly into a ScrollView... but you can have a FrameLayout and replace it at runtime with the map. Like this:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="-100dp"
android:layout_marginBottom="-100dp"
android:id="@+id/mapViewDetail"
android:scaleType="centerCrop"
xmlns:tools="http://schemas.android.com/tools"
android:layout_above="@+id/bottom_layout"
tools:context="com.yourpackage.app.HomeActivity"
tools:ignore="MergeRootFrame" />
Then I have created a custom map because I needed some "tweak" (you can avoid this step if you are fine with the default map):
public abstract class MiniMapFragment extends MapFragment {
@Override
public View onCreateView(LayoutInflater arg0, ViewGroup arg1, Bundle arg2) {
View v = super.onCreateView(arg0, arg1, arg2);
initMap();
return v;
}
public abstract void initMap();
}
Then, in the fragment I just added:
MiniMapFragment mMapFragment = new MiniMapFragment() {
@Override
public void initMap() {
googleMap = getMap();
getMap().getUiSettings().setMyLocationButtonEnabled(false);
getMap().getUiSettings().setZoomControlsEnabled(false);
getMap().getUiSettings().setScrollGesturesEnabled(false);
}
};
FragmentTransaction fragmentTransaction =
getFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.mapViewDetail, mMapFragment);
fragmentTransaction.commit();
getFragmentManager().executePendingTransactions();
MapsInitializer.initialize(this);
And you should be fine.
Upvotes: 1