Google Maps Embed API must be used in iframe in UIWebview

I'm trying to upload Google maps to UIWebview and call http://maps.google.com/?saddr=22.718019,75.884460&daddr=33.391823,-111.961731&zoom=10&output=embed , but it shows an error "The API for implementing Google Maps should used in iFrame in UIWebview "It worked so far, it does not work. I am trying to load this url in an iframe like this

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];

but it does not work and does not give some WebKitError.

Please help .. Thanks!

+4
source share
2 answers

Your iFrame implementation worked for me. Here is my method:

-(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];


}
+2

, Google "output = embed" . , 2014. . https://forums.embarcadero.com/message.jspa?messageID=642868 , IFRAME.

0

Source: https://habr.com/ru/post/1535882/


All Articles