If i start this application, i can see the webview correctly, but it doesn't load google maps (https://maps.google.com/maps?q=43.0054446,-87.9678884&t=m&z=7), but it loads the normal google page (https://www.google.it/#q=43.0054446%2C-87.9678884). Why? Is there a way to fix it?
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;
}
}
Now i have another problem. This is my xml Layout.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textview"
android:layout_height="@string/hello_world"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<WebView
android:id="@+id/mapview"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
I want to display the WebView in the upper half of the screen, but when the link is loaded, the page is fullscreen (even if i insert something else under the webview). Why?
I just removed the S from the httpS and it works. I don't know if this can help.
For me I was missing the myWebView.getSettings().setJavaScriptEnabled(true);
.
This is my code:
//set the webview and have open the map
mywebview = (WebView) findViewById(R.id.webView);
WebSettings webSettings = mywebview.getSettings();
webSettings.setBuiltInZoomControls(true);
mywebview.getSettings().setJavaScriptEnabled(true);
mywebview.setWebViewClient(new Callback());
mywebview.loadUrl(mapPath+map2);
Thanks to the commenter adding that, I was going a little nuts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With