Reputation: 31
How can I integrate bing map on the iPad or iPhone business application ?
Can anyone please help me ?
Upvotes: 3
Views: 1460
Reputation: 335
Bing Maps now has an iOS SDK so you can use it natively in your iOS apps:
Upvotes: 2
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 yourUIWebView
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:
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