馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
我用引用GOOGLE MAP V3 時 加入地圖
但是卻一片空白,也沒有錯誤
我參考了數則教程 感覺都差不多
例如一下這篇
http://nkeegamedev.blogspot.tw/2012/12/android-google-map-v3-1.html
但是始終不知道是什麼原因
以下是我的環境
---------------------------------------------------------------
以下是我的版本
[elicpse]
Eclipse Java EE IDE for Web Developers.
Version: Mars.1 Release (4.5.1)
[android manager]
Version: 24.4.4.1
全文網址: 引用 google 地圖錯誤-Android 軟體設計-Android 研發設計-Android 台灣中文網 - APK.TW http://apk.tw/thread-737643-1-1.html#ixzz3wLnpjZYQ
Power By APK.TW
-------------------------------------------------------------
下面是程式碼
[googlemap.html]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Google Maps JavaScript API v3 Example: Marker Animations</title>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false&language=zh-tw"></script>
<script>
<script type="text/javascript">
var map;
function initialize() {
var myLatlng = new google.maps.LatLng(23.937501, 120.700807);
var myOptions = {
zoom : 17,
center : myLatlng,
mapTypeId : google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(documnet.getElementById("map_canvas"),
myOptions);
}
</script>
</head>
<body>
<div id="map_canvas" style="width:100%;height:100%">
</div>
</body>
</html>
[MainActivity]
package com.example.mapv3;
//import com.example.gmapv3sample.R;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
public class MainActivity extends Activity {
private static final String MAP_URL="file:///android_asset/googlemap.html";
//private static final String MAP_URL="file:///asset/MapJs.html";
private WebView webView=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupWebView();
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private void setupWebView(){
webView=(WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(MAP_URL);
}
}
[activity_main.xml]
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_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="com.example.mapv3.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</WebView>
</RelativeLayout>
[AndroidMainfest.xml]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mapv3"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
|
|