2
、特にこの方法はAndroidのWebViewの
private void setupWebView(){
String MAP_URL = "http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html";
String centerURL = "javascript:centerAt(" + mostRecentLocation.getLatitude() + ","+ mostRecentLocation.getLongitude()+ ")";
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
//Wait for the page to load then send the location information
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url){
webView.loadUrl(centerURL);
}
});
webView.loadUrl(MAP_URL);
}
私が気づいたこと私が置いた場合、この
private void setupWebView(){
String MAP_URL = "http://gmaps-samples.googlecode.com/svn/trunk/articles-android-webmap/simple-android-map.html";
String centerURL = "javascript:centerAt(" + mostRecentLocation.getLatitude() + "," + mostRecentLocation.getLongitude()+ ")";
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
//Wait for the page to load then send the location information
webView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url){
//DO NOTHING
}
});
webView.loadUrl(MAP_URL);
webView.loadUrl(centerURL);
}
それはもはや作品のようなwebView.loadUrl(centerURL);
直後 webView.loadUrl(MAP_URL);
。だからcentreAt(..)
javascriptメソッドはMAP_URL
に含まれています。
URLが実際に読み込まれる前にwebView.loadUrl(..)
メソッドが返されているのだろうかと思います。 トップメソッドが完全にロードされてからJavaScriptが実行されるまで待ちますので、
うめき声を....私はちょうどそれを発見するために一日無駄にしました。しかたがない。ピーターを確認するための乾杯。 – Tim