krrish
krrish

Reputation: 31

Bing Map on the iPad/iPhone

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

Can anyone please help me ?

Upvotes: 3

Views: 1460

Answers (2)

Carl Stewart
Carl Stewart

Reputation: 335

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

New Bing Maps iOS SDK

Upvotes: 2

elp
elp

Reputation: 8131

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:

http://www.albertopasca.it/whiletrue/2010/10/iphone-microsoft-bing-map-iphone-ipad/

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.

Upvotes: 3

Related Questions