开发者

Bing Map on the iPad/iPhone

How can I integrate bing map on the iPad or iPhone business application ?

C开发者_如何学Pythonan anyone please help me ?


I write a javascript wrapper from BING Api to ObjectiveC.
It's not the best solution, but it works.

Objective-C offfer a method to call directly javascript from your code.

You can use stringByEvaluatingJavaScriptFromString from your UIWebView to call all of the js functions (zoom in, setmapType, etc...).

Your UIWebView must be a html page that contains a basic map.

Like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>
      <script type="text/javascript">
         var map = null;

         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap(new VELatLong(45.46347, 9.19404), 10 ,'h' ,false);
            map.HideDashboard();
            map.SetMapStyle(VEMapStyle.Road);
            map.SetZoomLevel(10);
         }   
      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:absolute; left:0px; top:0px; width:320px; height:460px;"></div>
   </body>
</html>

Bing reference (http://www.microsoft.com/maps/isdk/ajax/)

After a day you can reach this result:

Bing Map on the iPad/iPhone

Here an example of wrapped js (where map is a JS variable on your html page!):

- (void) setZoom:(int)level {
    [self stringByEvaluatingJavaScriptFromString:@"map.setZoom(%d);", level]];
}
- (void) setCenterPoint:(NSString*)point {
    [self stringByEvaluatingJavaScriptFromString:[@"map.setCenterPoint(%@);", point]];
}
- (void) zoomIn {
    [self stringByEvaluatingJavaScriptFromString:@"map.zoomIn();"];
}
- (void) zoomOut {
    [self stringByEvaluatingJavaScriptFromString:@"map.zoomOut();"];
}

You can use touch gestures and... much more!

Hope this helps!

Alberto.


Bing Maps now has an iOS SDK so you can use it natively in your iOS apps:

New Bing Maps iOS SDK

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜