android webview google map,Android的webview不会显示谷歌地图

在Android应用中,WebView无法加载谷歌地图页面,但可以加载普通谷歌页面。问题可能在于地图URL的处理。尝试检查WebView设置,如启用JavaScript,并确保已添加Internet权限。同时,确认WebView是否能正确显示其他网页,以排除特定网址问题。布局文件显示WebView全屏,需要调整布局以限制其大小并与其他内容共存。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如果我启动此应用程序,我可以正确地看到webview,但它不会加载谷歌地图(

https://maps.google.com/maps?q=43.0054446,-87.9678884&t=m&z=7),但它会加载正常的谷歌页面(

https://www.google.it/#q=43.0054446%2C-87.9678884).为什么?有办法解决吗?

public class MainActivity extends Activity

{

WebView myWebView;

String mapPath = "https://maps.google.com/maps";

@Override

protected void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

myWebView = (WebView)findViewById(R.id.mapview);

String map2="?q=43.0054446,-87.9678884&t=m&z=7";

myWebView.loadUrl(mapPath+map2);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

}

现在我有另一个问题.这是我的xml布局.

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity" >

android:layout_width="wrap_content"

android:layout_height="wrap_content">

android:id="@+id/textview"

android:layout_height="@string/hello_world"/>

android:layout_width="wrap_content"

android:layout_height="wrap_content">

android:id="@+id/mapview"

android:layout_width="wrap_content"

android:layout_height="wrap_content" />

我想在屏幕的上半部分显示WebView,但是当加载链接时,页面是全屏的(即使我在webview下插入了其他内容).为什么?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值