iPhone에서 Google지도를 더 빨리로드하는 방법
-
05-07-2019 - |
문제
iPhone 애플리케이션에서는 번들 HTML 페이지에서 웹 뷰에 운전 방향을로드하고 있습니다 (Mapkit에 직접로드 할 수있는 방법을 찾을 수 없기 때문에로드하는 데 너무 많은 시간이 걸리면 더 좋습니다. 그렇게하는 방법? iPhone 기본 맵 응용 프로그램에서와 마찬가지로
코드 :
NSString *filePathString = [[NSBundle mainBundle] pathForResource:@"drive_index" ofType:@"html"];
NSMutableString *html = [[NSMutableString alloc] initWithContentsOfFile: filePathString];
[html replaceOccurrencesOfString: @"varLocation1" withString:loc1
options: NSLiteralSearch range: NSMakeRange(0, [html length])];
[html replaceOccurrencesOfString: @"varLocation2" withString:loc2
options: NSLiteralSearch range: NSMakeRange(0, [html length])];
NSURL *aURL = [NSURL fileURLWithPath:filePathString];
[webView loadHTMLString:html baseURL:aURL];
및 HTML 페이지
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example: Simple Map</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
type="text/javascript"></script>
<script type="text/javascript">
var directionsPanel;
var directions;
var location1="varLocation1";
var location2="varLocation2";
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(location1), 13);
directionsPanel = document.getElementById("route");
directions = new GDirections(map, directionsPanel);
directions.load('from: ' + location1 +' to: '+ location2 );
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width:divice-width ; height:350px ; float:top; border: 1px solid black;"></div>
<div id="route" style="width:divice-width; border; 1px solid black;"></div>
</body>
</html>
해결책
이 답변을 살펴보십시오.
맵 키트 (운전 방향은 포함되지 않음)와 오버레이 라인을 직접 사용하는 방법이 있습니다. 다음은 그들이 참조하는 사이트입니다.
다른 팁
전환 할 수 있는지 확실히 확인해야합니다 Google Maps API의 V3. 모바일 브라우저에 빠르게로드하도록 특별히 설계되었습니다. 유일한 문제 (그리고 큰 문제는 큰 문제)는 아직 방향을 지원하지 않는다는 것입니다.
제휴하지 않습니다 StackOverflow