2012-07-26 4 views
0

지도를 탭하거나 클릭하는 곳에서 위도와 경도를 어떻게 얻을 수 있습니까? 나는 정보 좌표 클래스를 찾았지만 그것이 totaly diffrent이며, 또한 내가 변환 할 수 없습니다 Windows 8에서 위도와 경도를 얻는 방법 Metro Bing Map app

메트로

나는 정보 좌표 클래스를 사용하여 예제를 발견하지만 윈도우 7 모바일의 샘플이고,이 클래스는하지 승 8에 존재 않습니다 내 같은이 클래스에 맵이 샘플에서

승 7에서 내 샘플이 지금 만든 새로운 프로젝트에 관해서는이

Point p = e.GetPosition(this.MapMain); 
GeoCoordinate geo = new GeoCoordinate(); 
geo = MapMain.ViewportPointToLocation(p); 

처럼 보이는, 빙지도와 세트 조치를 도청했다. 그러나 나는 아무 생각이 시도

+1

창문 지하철 7 샘플, 매우 다른 보지 않습니다. Theres windows 8 geolocations samples here : http://code.msdn.microsoft.com/windowsapps/Geolocation-2483de66 –

+0

thx 가능한 빨리 확인해 보겠습니다. – Fixus

답변

1

탭을 기준으로 좌표를 얻는 방법을 어디서든 찾을 수 없습니다 :

Point p = e.GetPosition(this.MainMap); 
Location location = new Location(); 
MainMap.TryPixelToLocation(p, out location); 

위치 변수는 위도와 경도 값을 가질 것이다.

0

첫째, 클릭 이벤트에 대한 이벤트 리스너를 추가 :

Microsoft.Maps.Events.addHandler (지도, mapClick을 '클릭'); 그런 다음 이벤트 처리기에서

:

기능 mapClick (E) {

if (e.targetType == "map") { 

    //Get x and y 

    var point = new Microsoft.Maps.Point(e.getX(), e.getY()); 

    //Convert map point to location 

    var location = e.target.tryPixelToLocation(point); 

    console.log(location.longitude); 

    console.log(location.latitude); 
} 

}

0
// --------- HTML/JS -------------- 
var mapCenter = map.getCenter(); 
var pos = map.tryPixelToLocation(new Microsoft.Maps.Point(location.clientX, location.clientY), Microsoft.Maps.PixelReference.control); 

// --------- C# ------------------- 
Geolocator geolocator = new Geolocator(); 
var pos = await geolocator.GetGeopositionAsync(); 
Location location = new Location(pos.Coordinate.Latitude, pos.Coordinate.Longitude); 
관련 문제