2017-02-14 4 views
0

1つのアクティビティ(MainActivity)がフラグメント(MainPage)を呼び出します。このフラグメントは、ローカルアセットWebviewファイルMap.htmlを開くように設計されています。マップは指先で動かすことができないの例外を除いて、意図したとおりに動作します。この関数は、Map.htmlがbroswerを開いたときに使用できます。ただし、左上のズームインズームアウトタップボタンが機能します。Webviewでマップを移動できません

見えるがスワイプされないように、webviewにオーバーレイされているものはありますか?

Map Screenshot

初期AppCompatActivity(アクションバーをサポートするためには)MainActivityによって与えられる。このため、XMLは次のように与えられる

public class MainActivity extends AppCompatActivity implements View.OnClickListener{ 

    //list of private declarations 

    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 

    // a lot of other stuff relating to navigation drawer 

    // calls MainPage Fragment 
    android.support.v4.app.Fragment fragment = new MainPage(); 
       FragmentManager fragmentManager = getSupportFragmentManager(); 
       fragmentManager.beginTransaction() 
         .replace(R.id.content_frame, fragment) 
         .addToBackStack("tag") 
         .commit(); 
    } 
} 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_centerVertical="true" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 

    <android.support.v4.widget.DrawerLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/drawer_layout" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

    <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/content_frame"> 
    </WebView> 

     <ListView 
      android:id="@+id/left_drawer" 
      android:layout_width="240dp" 
      android:layout_height="match_parent" 
      android:layout_gravity="start" 
      android:choiceMode="singleChoice" 
      android:divider="@android:color/transparent" 
      android:dividerHeight="0dp" 
      android:background="#111"> 
     </ListView> 

    </android.support.v4.widget.DrawerLayout> 

</LinearLayout> 

が最終的にメインページを呼び出し、指定されましたとして:

public class MainPage extends android.support.v4.app.Fragment implements GeolocationPermissions.Callback { 

    public MainPage() { 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View rootView = inflater.inflate(R.layout.activity_main, container, false); 
     WebView webview = (WebView) rootView.findViewById(R.id.content_frame); 
     webview.getSettings().setJavaScriptEnabled(true); 
     webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); 
     webview.getSettings().setGeolocationEnabled(true); 
     GeoClient geo = new GeoClient(); 
     webview.setWebChromeClient(geo); 
     String origin = ""; 
     geo.onGeolocationPermissionsShowPrompt(origin, this); 
     webview.loadUrl("file:///android_asset/Map.html"); 
     return rootView; 
    } 

答えて

0

あなたはonclicklistenerを設定する必要があるかもしれません。 Googleマップの場合、これが私のやり方です。おそらく似ています。

implements、@override関数を追加し、onclickリスナーを設定します。ある時点でHTMLを使用しているので、これが機能するかどうかはわかりません。

public class MainActivity extends FragmentActivity implements View.OnClickListener, 
     GoogleMap.OnMapClickListener { 

次に、オンマップクリックリスナーを設定します。

@Override 
public void onMapClick(LatLng point) { 
//What code if any happens when user clicks on map 
} 

gMap.setOnMapClickListener(this);// add the listener for click on gmap object 

最後に、この@Overrideを追加

関連する問題