我正在尋找關於如何在Google地圖上顯示興趣點(保存在融合表中)的示例。Google地圖上的Fusion Tables v2 POI:Android示例?
要做到這一點HTML和JavaScript這是相當瑣碎,檢查我的javascript map with fusion tables example
見Fusion Tables page containing my POIs
我的目標/問題是如何(需要編碼它的幫助),以達到相同的Android應用中。我對android開發很陌生,並且我已經投入了數小時的基礎知識並檢查文檔和示例。
檢查這個很好Google Maps example for Android我發現開始了(我的測試應用程序是基於這段代碼的)。
Fusion Tables v2 reference(指向Google API用戶端)
Google API Java client samples on github(最過時的:在V1的例子)
到目前爲止,我實現了顯示地圖集中於我的最後已知位置,並顯示出它的標誌。
因爲我無法找到很好的例證,我決定發佈和分享我的調查結果,請參見:firepol/android-google-maps-fusion-tables on github
現在我想顯示從融合表來標記。 我被困在執行請求,我試圖通過谷歌API客戶端。
Google API client example for Android
ActivityFeed feed = listActivities.execute();
這裏我的代碼(我已經把裏面的onCreate):
protected void prepareFusion() {
// Normally READONLY should be enough (see credential with one scope), but I checked online a console
// and I could see a public table only if I would grant both permissions
List<String> scopes = new ArrayList<>(Arrays.asList(FusiontablesScopes.FUSIONTABLES, FusiontablesScopes.FUSIONTABLES_READONLY));
credential = GoogleAccountCredential.usingOAuth2(this, scopes);
//credential = GoogleAccountCredential.usingOAuth2(this, Collections.singleton(FusiontablesScopes.FUSIONTABLES_READONLY));
// TODO : get account name automatically
// http://stackoverflow.com/questions/35789071/getting-the-gmail-id-of-the-user-in-android-6-0-marshmallow
credential.setSelectedAccountName("YOUR_GOOGLE_ACCOUNT");
client = new Fusiontables.Builder(
transport, jsonFactory, credential).setApplicationName("TestMap/1.0")
.build();
try {
String tableId = "1774o_WcrqSQlepLXlz1kgH_01NpCJ-6OyId9Pm1J";
Fusiontables.Query.Sql sql = client.query().sql("SELECT FileName,Name,Location FROM " + tableId);
//sql.execute();
//java.lang.IllegalStateException: Calling this from your main thread can lead to deadlock
Fusiontables.Table.Get table = client.table().get(tableId);
table.setFields("items(FileName,Name,Location)");
//table.execute();
// TODO : can't execute like this on main thread as the documentation example "suggests"
//https://developers.google.com/api-client-library/java/google-api-java-client/android
} catch (IOException e) {
e.printStackTrace();
}
}
如果我試圖做同樣的,並呼籲sql.execute()或table.execute ()我得到:
java.lang.IllegalStateException:從您的主線程調用 可能導致死鎖k
所以我有點卡在這裏,我想知道如何從有經驗的谷歌API客戶端的人開始,甚至更好,如果你能幫助我在地圖上得到結果!謝謝。
如何在地圖上顯示融合表POI?
要看到我堅持,並幫助我,我的克隆GitHub庫firepol/android-google-maps-fusion-tables on github,Android Studio中打開它,加入自己的谷歌地圖API密鑰和調試設備。感謝您的建設性意見,答案和幫助。隨意推動Github以及。
Thx。有一個更新的教程或代碼示例使用谷歌api客戶端的異步任務嗎?我會看看也是Robospice等找到一個很好的介紹,以比較它們:https://www.reddit.com/r/androiddev/comments/3d1iim/retrofit_volley_or_robospice_and_jackson_or_gson / – firepol