zivlo

iOS App display local HTML file can't load esri.map correct

Discussion created by zivlo on Jan 23, 2013
hi,

I use iOS UIWebView control load the local HTML file from app document folder, but the map can't display correct.
The HTML file can display map correct when the file in the web server and use PC browser viewing.

UIWebView code
[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath: htmlFile]]];


HTML & JavaScript code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.4/js/dojo/dijit/themes/tundra/tundra.css" />
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.4"></script>

  <script type="text/javascript">
   dojo.addOnLoad(function () {
  var map = new esri.Map("map");
  var mapURL = "http://sisg.ntpc.gov.tw/ArcGIS/rest/services/map/MapServer?token=9Ngd-reXfxR7LIqjFi1K3ldeCJsz1xh24OqWLKURuyRmcPGBXcEbYqCzFl4zyGBr1yP-WYLnRMJBRXIzPN2r6w..";
  map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer(mapURL));
 });
  </script>
</head>
<body>
<div id="map" style="width:400px;height:400px;" />
</body>
</html>


The javascript use esri.map with esri.layers.ArcGISTiledMapServiceLayer to build the map, and the token is from our customer, it is restrict by our IP address.

I use proxy on iPad connection to get the HTTP information at below.

Request raw
GET /ArcGIS/rest/services/map/MapServer?f=json&token=9Ngd-reXfxR7LIqjFi1K3ldeCJsz1xh24OqWLKURuyRmcPGBXcEbYqCzFl4zyGBr1yP-WYLnRMJBRXIzPN2r6w..&callback=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback HTTP/1.1
Host: sisg.ntpc.gov.tw
User-Agent: Mozilla/5.0 (iPad; CPU OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405
Accept: */*
Accept-Language: zh-tw
Accept-Encoding: gzip, deflate
Connection: keep-alive
Connection: keep-alive

Response raw
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/plain;charset=utf-8
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Thu, 24 Jan 2013 05:46:43 GMT
Content-length: 113
Connection: close
Set-Cookie: agstoken=; expires=Mon, 24-Jan-1983 05:46:44 GMT; path=/

dojo.io.script.jsonp_dojoIoScript1._jsonpCallback({"error":{"code":498,"message":"Invalid token","details":[]}});


Please tell me how to fix this issue, thanks.

Oh, i also need to know how to destory/unload map on javascript code, is there has any method to do?

Regards,
Ziv

Outcomes