views:

642

answers:

1

as we all know that driving direction is not supported in mapkit.so i think i can show driving direction in webview.i am showing google maps in uiwebview,but it shows the whole site i just want to show only map part with some zoom so that it looks like original maps application of iphone.also i don't know if this breaks the apple's Human Interface Guidelines(HIG) Rules,tell me if it is

A: 

Load a string like this as an NSString (maybe strip the newlines). You can change the latitude and longitude, zoom level etc with stringWithFormat

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"&gt;&lt;/script&gt;
<script type="text/javascript">
  function initialize() {
 var latlng = new google.maps.LatLng(35.000, 139.000);
 var myOptions = {
   zoom: 15,
   center: latlng,
   mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }
</script>
</head>
<body onload="initialize()">
 <div id="map_canvas" style="width:100%; height:100%">
</body>
</html>

Then set your UIWebViews html to that. It will give you a page with just a map on it, allow you to scroll with your finger or zoom in, pinch zoom, and place a marker.

Use this to load the HTML:

- (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
nevan
i want to show driving direction can you tell me how to do that with your code.i have two lat/longs locations,also what parameter shoul i pass into baseURL in the method - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL
Rahul Vyas
also tell me if i use this will the app rejected by apple
Rahul Vyas
please post a sample code for this
Rahul Vyas
This should be enough to get you started, now you have to work out how to make a web page with driving directions. I can't help you with that. As to the app getting rejected by Apple, it's impossible to say. Any app you submit, you take a gamble whether it's going to be accepted or not.
nevan