Google Maps Platform rejected your request. Invalid 'pb' parameter

10,932

Solution 1

A seamless approach to this would be:

  1. Search for the place you want to include on your iframe on Google Maps

  2. Click on the share buttonshare button

  3. When the modal opens, click on the Embed a map tab copy html button

  4. Copy the HTML code of the map size you're after, and paste it inside your iframe.

Solution 2

The URL inside iframe in your example looks like a link obtained from share location on Google Maps web site. Typically this URL shouldn't be treated as Google Maps Platform product. However, for some reason Google treats it as Google Maps Platform in the WebView component.

I think this is a bug on Google side.

The workaround is replacing URL for share with URL from Google Maps Embed API. In this case you will have correct Google Maps Platform link and it should work as expected. Note that you will need a valid API key in order to use Google Maps Embed API.

The code snippet is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
    <body>
      <iframe width="600" height="450" frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?q=The+Westin+Turtle+Bay+Resort+%26+Spa%2C+Mauritius&key=AIzaSyDztlrk_3CnzGHo7CFvLFqE_2bUKEq1JEU" allowfullscreen></iframe>
    </body>
</html>

You should replace my API key with yours.

I hope this helps!

Share:
10,932
Sanjeev
Author by

Sanjeev

#SOreadytohelp : Passionate about Java, Android, React-Native and front end development , still learning and happy to help and get help :D Checkout react-native e-commerce app on github

Updated on June 04, 2022

Comments

  • Sanjeev
    Sanjeev about 2 years

    I am trying to show Google map in webview, but it is saying

    Google Maps Platform rejected your request. Invalid request. Invalid 'pb' parameter.

    But when I am rendering the same iframe on web browser, it is working perfectly

    here is what I am trying to render in webview, this is the string stored in variable iframeData

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
        <body>
            <iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14988.154038971099!2d57.510438!3d-20.090677!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0xc479c0ed4774c8e7!2sThe+Westin+Turtle+Bay+Resort+%26+Spa%2C+Mauritius!5e0!3m2!1sen!2smu!4v1513055435928" width="340.0" height="250" frameborder="0" style="border:0" allowfullscreen></iframe>
        </body>
    </html>
    

    And this is my Android code to render this iframe into webview

    String iframeData = //look above
    
    WebView webViewMap = (WebView) rootView.findViewById(R.id.webViewMap);
    WebSettings settings = webViewMap.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(false);
    settings.setUseWideViewPort(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        settings.setAllowUniversalAccessFromFileURLs(true);
    }
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webViewMap.loadData(iframeData, "text/html", null);
    

    Screenshot

    • xomena
      xomena over 5 years
      The URL doesn't look like a Google Maps Embed API URL. How did you create this URL? Is it copied from the share option of web interface?
    • Sanjeev
      Sanjeev over 5 years
      I have a magento website, there this iframe is embeded and the map is showing, this same iframe data is sent in API and I am trying to render it in WebView. For other prdocuts it is working fine, but for this particular iframe it is not showing in Android
    • Sean Breckenridge
      Sean Breckenridge almost 5 years
      I got my iframe link from the "share/embed" item In my case, The name of the location I was trying to pin had an apostrophe in it and it was encoded in the URL as &#39; which threw the error. Removing that fixed the error and seems to have not affected the name when you click the pin,.
  • Sanjeev
    Sanjeev over 5 years
    Thank you, And yes using Embed API like you mention worked, but the embed data that i mentioned is working fine on Website and IOS, it is just not working for Android and that too only this case all the other embedded map like mine are rendering, do you have any idea what might be causing this?
  • xomena
    xomena over 5 years
    In my opinion this is a bug on Google side. You should report it in the Google public issue tracker.
  • R. A.
    R. A. almost 5 years
    Hi @L-X, did you find a final solution for this embedded link problem. After several hours of debugging and checking every character in the links I tried encoding and it worked, maybe it can help you.