운전 경로는 MapKit에서 지원되지 않습니다. 그래서 나는 웹 뷰에서 운전 방향을 보여줄 수 있다고 생각합니다. uiwebview에서 Google지도를 보여주고 있지만 전체 사이트를 보여줍니다. 일부지도 만 표시하고 싶기 때문에 iphone의 원본지도 응용 프로그램처럼 보입니다. 또한 이것이 사과의 휴먼 인터페이스 가이드 라인 (HIG) 규칙을 어기는 지 모르겠다면 말해주십시오.확대/축소와 함께 UIWebView를 사용하여 Google지도 표시
4
A
답변
7
NSString (이와 같이 줄 바꿈을 제거 할 수 있음)과 같이 문자열을로드하십시오. 당신은
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(35.000, 139.000);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%">
</body>
</html>
stringWithFormat
이 그런 다음에 UIWebView
의 HTML을 설정하여 위도와 경도, 줌 레벨 등을 변경할 수 있습니다. 지도가있는 페이지를 제공하며 손가락으로 스크롤하거나 확대하고 핀치 확대/축소하고 마커를 배치 할 수 있습니다.
- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
4
당신이가는 :
사용이 HTML을로드합니다. 원점 위도가 두 배 길고 대상 위도가 long 인 두 번으로 stringWithFormat을 통해 전달합니다. 모두 float 형식으로 전달합니다.
[NSString stringWithformat : ... oriLat, oriLon, oriLat, oriLon, destLat, or destill]; 난에 통과 말아야 또한 어떤 매개 변수
다음
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
var directionsDisplay = new google.maps.DirectionsRenderer();
var directionsService = new google.maps.DirectionsService();
function initialize() {
var latlng = new google.maps.LatLng(%f, %f);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
directionsDisplay.setMap(map);
calcRoute();
}
function calcRoute() {
var start = new google.maps.LatLng(%f, %f);
var end = new google.maps.LatLng(%f, %f);
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:300px; height:300px">
</body>
</html>
+0
어떻게해야할까요? html을 문자열로 추가하는 것을 의미합니다. 고마워 – MJB
내가 어떻게 당신의 code.i 두 가지를 함께 위도 /이 위치를 갈망 그렇게 말해 줄 수있는 방향을 운전 보여주고 싶은있는 UIWebView로 전달, 메서드의 baseURL - (void) loadHTMLString : (NSString *) string baseURL : (NSURL *) baseURL –
이 앱을 사과로 거절하면 알려 주겠다 –
이 샘플 코드를 게시하시기 바랍니다. –