Android 앱에지도 컨트롤을 추가하고 싶습니다. 이를 위해 Nuget의 최신 xamarin.forms 및 xamarin.forms.maps 패키지가 있습니다.
논리 뒤에있는 내 코드는 전혀 작동하지 않으며 내 axml 페이지는 다음과 같습니다.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/optionsContainerLinearLayout">
//Other UI elements
<maps:Map>
</maps:Map>
</LinearLayout>
...
</LinearLayout>
오류 가능성을 최소화하기 위해 maps : Map 내에 태그가 없습니다. 바로 아래에있는 것처럼 더 많은 속성으로이지도를 채울 때 코드는 여전히 동일한 방식으로 중단됩니다.
<map:Map
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/mockMapView">
</map:Map>
이 응용 프로그램을 실행 SetContentView()
하면 오류가 발생합니다.
Didn't find class "android.view.Map" on path: DexPathList
[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/com.geosolve.pavestate2-fJtHBLcT2gY6AlUrxcOOVg==/base.apk"],
nativeLibraryDirectories=[/data/app/com.geosolve.pavestate2-fJtHBLcT2gY6AlUrxcOOVg==/lib/x86, /data/app/com.geosolve.pavestate2-fJtHBLcT2gY6AlUrxcOOVg==/base.apk!/lib/x86, /system/lib]]
내 에뮬레이터에서 잘 실행되는 또 다른 샘플 xamarin 응용 프로그램이 있으므로 에뮬레이터가 문제라고 생각하지 않습니다. 이 다른 응용 프로그램에서도 내 API 키를 사용하고 있으므로 API 키도 문제라고 생각하지 않습니다.
내 androidManifest.xml은 다음과 같습니다.
...
<application android:allowBackup="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:roundIcon="@mipmap/icon" android:supportsRtl="true" android:theme="@style/GeosolveApp">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="(My API Key)" />
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
...
왜 이것이 아닌지에 대한 도움이 있습니까? 예상했던 것처럼 나타나지 않습니까?
Xamarin.Android의 경우 일반적으로 NuGet에서 Xamarin.GooglePlayServices.Maps 패키지를 설치합니다 .
그리고 다음과 같이 xaml에 맵을 추가하십시오.
선언적으로 :
<fragment 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:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment" />
프로그래밍 방식 :
var mapFrag = MapFragment.NewInstance();
activity.FragmentManager.BeginTransaction()
.Add(Resource.Id.map_container, mapFrag, "map_fragment")
.Commit();
Google지도를 더 많이 읽을 수 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다