안녕하세요 전 gps 위치를 취해야하고 위도와 경도를 forcast.io에 대한 URL에 결합 해야하는 xamarin 양식의 응용 프로그램에서 일하고 있습니다. Geolocator 플러그인을 사용하고 있습니다. 제임스 Montemagno 및 추가 정보를 다음에하지만 난 여전히 이러한 오류를 받고 있어요 :제임스 Montemagno에 의해 Geolocator의 xamarin 플러그인과 문제가
'MSI'심각도 코드 설명 프로젝트 파일 라인 할당되지 않은 지역 변수의
심각도 코드 설명 프로젝트 파일 라인 억제 상태 오류 CS0165 사용 억제 상태 오류 CS0266 암시 적으로 형식을 변환 할 수 없습니다 'Plugin.Geolocator.Abstractions.IGeolocator'to 'Plugin.Geolocator.CrossGeolocator'. 명시 적 변환은 가 (당신이 캐스트를 누락?) 존재
는심각도 코드 설명 프로젝트 파일 라인 억제 상태 CS1061 'CrossGeolocator' 에 대한 정의를 포함하지 않는 'IsGeolocationEnabled'없이 확장 방법은 '을 IsGeolocationEnabled' 오류가 을 수용 유형 'CrossGeolocator'의 첫 번째 인수는 (당신은 using 지시문 또는 어셈블리 참조가?) 볼 수 있습니다
이 이심각도 코드 설명 프로젝트 파일 라인 억제 상태가 오류 CS1061 'CrossGeolocator은' 에 대한 정의를 포함하지 않는 'GetPositionAsync'및 유형 'CrossGeolocator'의 첫 번째 인수를 받아들이는 더 확장 메서드 'GetPositionAsync' 는 (당신은 using 지시문 또는 어셈블리 참조가?) 찾을 수 없습니다
심각도 코드 설명 프로젝트 파일 라인 억제 상태 오류 CS1061 'CrossGeolocator을 볼 수 있습니다 DesiredAccuracy '없이 확장 메서드'CrossGeolocator '형식의 첫 번째 인수를 을 받아'DesiredAccuracy ' 에 대한 정의를 포함하지 않는'(using 지시문 또는 어셈블리 참조가 당신에게 이다?)
그리고 나서 여기에 그는 레이더 코드 :
using Xamarin.Forms;
using System;
using System.Diagnostics;
using Plugin.Geolocator;
namespace AppName.Radar
{
public interface MyLocationTracker
{
void ObtainMyLocation();
event EventHandler<MyLocationEventArgs> locationObtained;
}
public interface MyLocationEventArgs
{
double lat { get; set; }
double lng { get; set; }
}
public partial class RadarHome : ContentPage
{
private readonly CrossGeolocator _locator;
private double BetaLat;
private double BetaLog;
public RadarHome()
{
MyLocationTracker msi;
_locator = CrossGeolocator.Current;
if (_locator.IsGeolocationEnabled == false)
{
if (Device.OS == TargetPlatform.Android)
{
msi.locationObtained += (object Esender, MyLocationEventArgs ew) =>
{
Debug.WriteLine(ew.lat);
};
msi.ObtainMyLocation();
}
else if (Device.OS == TargetPlatform.iOS)
{
msi = DependencyService.Get<MyLocationTracker>();
msi.locationObtained += (object Jsender, MyLocationEventArgs je) =>
{
Debug.WriteLine(je.lat);
};
msi.ObtainMyLocation();
}
}
_locator.DesiredAccuracy = 50;
GetPositionAsynchronously();
string str = string.Format(
"https://forecast.io/?mobile=1#/f/Lat:{0} , Long: {1}", BetaLat, BetaLog);
var client = new System.Net.Http.HttpClient();
client.BaseAddress = new Uri(str);
}
private async void GetPositionAsynchronously()
{
//will run asynchronously in a diff thread
var position = await _locator.GetPositionAsync(timeoutMilliseconds: 100000);
BetaLat = position.Latitude; //will work
BetaLog = position.Longitude; // will work
}
}
}
나는 (Froms, 아이폰 OS, 안드로이드) 내가 VS2015 업데이트 3을 사용하고 아직도 형태 xamrarin 배우고 그래서 나는 그런 질문에 대한 미안 해요 3 개 플랫폼에 설치된 최신 Geolocator의 nuget 패키지가 멍청한 놈.
미리 감사드립니다.
그 역시 효과가있었습니다. 그 덕분에 대단히 고맙습니다 – Phoneswapshop