Android アプリケーションにYandex マップを追加したいと考えています。
質問は少し長く見えるかもしれませんが、それはすべてのコードを共有したためです。しばらくお待ちいただきますようお願いいたします。
当然のことながら、Google マップと比較して多くのソースを見つけることができませんでした。
このソースを使用しましたまず、簡単なサンプルを実行したいと思いました。ということでこちらのサンプルを使用。 最後に、私は何かを達成しました。エラーは発生しません。しかし、地図も表示できませんでした。四角い領域(チェッカー、チェック) と 1 つの「ターゲット アイコン」しかありません。以下のアクティビティ クラス コードを確認できます。
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;
//import ru.mapkittest.R;
import ru.yandex.yandexmapkit.*;
import ru.yandex.yandexmapkit.overlay.location.MyLocationItem;
import ru.yandex.yandexmapkit.overlay.location.OnMyLocationListener;
/**
* MapLayers.java
*
* This file is a part of the Yandex Map Kit.
*
* Version for Android © 2012 YANDEX
*
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://legal.yandex.ru/mapkit/
*
*/
public class MapMyLocationChangeActivity extends Activity implements OnMyLocationListener{
/** Called when the activity is first created. */
MapController mMapController;
LinearLayout mView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("Title");
setContentView(R.layout.activity_main);
final MapView mapView = (MapView) findViewById(R.id.map);
mapView.showBuiltInScreenButtons(true);
mMapController = mapView.getMapController();
// add listener
mMapController.getOverlayManager().getMyLocation().addMyLocationListener(this);
mView = (LinearLayout) findViewById(R.id.view);
}
@Override
public void onMyLocationChange(MyLocationItem myLocationItem) {
// TODO Auto-generated method stub
final TextView textView = new TextView(this);
textView.setText("Type " + myLocationItem.getType()+" GeoPoint ["+myLocationItem.getGeoPoint().getLat()+","+myLocationItem.getGeoPoint().getLon()+"]");
runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mView.addView(textView);
}
});
}
}
以下は私のレイアウトファイルです。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="gcm.b4deploy.com.yandexmap.MainActivity"
tools:showIn="@layout/activity_main"
android:orientation="vertical"
>
<ru.yandex.yandexmapkit.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="300dip"
android:apiKey="myapikey" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
</LinearLayout>
また、build.gradle ファイルの依存関係の下に次の行を追加しました。
compile 'ru.yandex:yandexmapkit:2.4.2@aar'
また、このブロックを外側の build.gradle ファイルに追加しました。
allprojects {
repositories {
jcenter()
maven { url 'https://github.com/yandexmobile/yandexmapkit-android/raw/maven/' }
}
}
次のスクリーンショットは、genymotion からの出力です。何が欠けているのですか、なぜ地図を表示できないのですか。実際、上記のソースはロシア語であるため、できる限りのことをしようとしましたが、何かを見逃している可能性があります. 何か案が?Androidアプリにyandexマップを追加する方法について私に提案できる別のソースまたはドキュメント(英語)が存在する場合は、それを見てみたい. 前もって感謝します。