Xamarin을 사용하여 내부에 Google지도가 포함 된 활동이있는 Android 앱을 디자인하고 있지만지도를 표시하는 데 어려움을 겪고 있습니다. 지도가 표시되지 않은 빈 상자가 표시됩니다. 다음은이 연습에 사용한 코드입니다.
My Activity
namespace teslin
{
[Activity(Label = "Map")]
public class MpActivity : Android.GoogleMaps.MapActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MapView);
var map = FindViewById<MapView>(Resource.Id.mapv);
map.Clickable = true;
map.Controller.SetZoom(16);
map.Controller.SetCenter(new GeoPoint((int)40.8270449E6, (int)-73.9279148E6));
}}
xml lay out
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3"
android:layout_weight="9" />
<com.google.android.maps.MapView
android:id="@+id/mapv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:enabled="true"
android:apiKey="AIzaSyD-UMij5IO6ezjuFCNnF7tRoG3niaPbNEU" />
</LinearLayout>
오래되었거나 오래된 Maps API v1을 사용하고있는 것 같습니다 . Google은 작년에 대한 지원을 제거했습니다.
대신 Android Maps API v2 (Google Play 서비스의 일부) 를 사용하려고합니다 . Xamarin에는 Android 의지도에 대한 몇 가지 설명서 가 있습니다. Android에서지도를 작동시키는 것은 약간 까다로울 수 있으므로이 문서를주의 깊게 읽으십시오. 특히 Maps API 에 대한 섹션을 읽고 싶을 것 입니다.
이 Github에서에 대한 예를 보여줍니다이 방법을 사용하는 것을 구글 플레이 서비스 구성 요소를 응용 프로그램에지도를 추가 할 수는.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다