2017-02-14 21 views
0

Одно действие (MainActivity) вызывает фрагмент (MainPage). Фрагмент предназначен для открытия локального файла веб-ресурсов, Map.html. Он работает по назначению, за исключением того, что карту нельзя перемещать кончиком пальца. Эта функция доступна, когда Map.html открывается броузер. Тем не менее, кнопка увеличения масштаба изображения в левом верхнем углу работает.Невозможно переместить карту в webview

Есть ли что-то, что накладывается на веб-просмотр, чтобы его можно было увидеть, но не проскочить?

Map Screenshot

Начальная AppCompatActivity (для поддержки ActionBar) задается MainActivity:

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 для этого дается как:

<?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> 

В конце концов вызывает MainPage, учитывая as:

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 Maps это так я сделал. Вероятно, это похоже.

Добавьте инструменты, функцию @override и установите прослушиватель onclick. Я не уверен, что это сработает, так как вы используете HTML в какой-то момент.

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

Затем, когда вы его инициируете, установите прослушиватель кликов onmap.

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

Наконец, добавьте @Override:

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