綁定帳號登入

Android 台灣中文網

打印 上一主題 下一主題

[求助] google map V3

[複製連結] 查看: 1122|回覆: 4|好評: 0
跳轉到指定樓層
樓主
richardcai | 收聽TA | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
發表於 2016-1-5 15:19

馬上加入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>

「用Android 就來APK.TW」,快來加入粉絲吧!
Android 台灣中文網(APK.TW)
收藏收藏 分享分享 分享專題
用Android 就來Android 台灣中文網(https://apk.tw)
回覆

使用道具 舉報

沙發
g198507 | 收聽TA | 只看該作者
發表於 2016-1-8 17:24
res --> values --> google_maps_api.xml
文件內有沒有設定API KEY?
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

板凳
 樓主| richardcai | 收聽TA | 只看該作者
發表於 2016-1-8 19:54
那不是V2才需要嗎???
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

地板
tuguhk | 收聽TA | 只看該作者
發表於 2016-1-31 01:41
始終不知道是什麼原因????
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

5
jasonb122 | 收聽TA | 只看該作者
發表於 2016-4-19 15:00
V3不是給網頁用的嗎? 用V2試試看
用Android 就來Android 台灣中文網(https://apk.tw)
回覆 支持 反對

使用道具 舉報

您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則