我正在尝试在UIWebview上加载谷歌地图并调用http://maps.google.com/?saddr=22.718019,75.884460&daddr=33.391823,-111.961731&zoom=10&output=embed,但它显示错误“必须在UIWebview中的iFrame中使用Google Maps Embed API”它之前正在工作它不能正常工作。我我正试图在iframe中加载此网址
NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f&zoom=10",[self.startLat floatValue], [self.startLon floatValue], [self.destLat floatValue],[self.destLon floatValue]];
NSString *embedHTML = [NSString stringWithFormat:@"<iframe width=\"300\" height=\"250\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe>" ,googleMapsURLString];
NSString *html = [NSString stringWithFormat:embedHTML];
但它没有工作并给出了一些WebKitError。
请帮忙.. 谢谢!
答案 0 :(得分:2)
您对iFrame的实施对我有用。这是我的方法:
-(void)showMapOnWebview:(UIWebView*)webview withUrl:(NSString*)urlAddress
{
//Create a URL object.
NSURL *url = [NSURL URLWithString:[urlAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *embedHTML = [NSString stringWithFormat:@"<html><head><title>.</title><style>body,html,iframe{margin:0;padding:0;}</style></head><body><iframe width=\"%f\" height=\"%f\" src=\"%@\" frameborder=\"0\" allowfullscreen></iframe></body></html>" ,webview.frame.size.width,webview.frame.size.height, url];
[webview loadHTMLString:embedHTML baseURL:url];
}
答案 1 :(得分:0)
是的Google已停止使用此参数“output = embed”进行调用。我认为2014年4月。请参阅https://forums.embarcadero.com/message.jspa?messageID=642868了解使用IFRAME方法的解决方法。
史蒂夫