html 手机端无法拖动地图,无法在webview中移动地图

一项活动(MainActivity)调用一个片段(MainPage)。该片段旨在打开本地资产webview文件Map.html。它按预期工作,但地图不能通过指尖移动。当Map.html打开一个浏览器时,此功能可用。但是,左上方的缩小分接按钮确实有效。无法在webview中移动地图

覆盖webview的东西,它可以被看到但没有被刷过?

DBVV7.jpg

初始AppCompatActivity(支持动作条)由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被给定为:

android:layout_centerVertical="true"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal">

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/drawer_layout"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:id="@+id/content_frame">

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

最终调用的MainPage,给定如:

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;

}

2017-02-14

Iorek

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值