DEV Community

Mohit Saud
Mohit Saud

Posted on

Invalid pb parameter solution while embedding google maps.

Invalid pb parameter solution while embedding google maps
Original Issue: When trying to embed a Google Maps location for "Hotel Yak & Yeti" using an iframe, the "pb" parameter in the embedded URL caused an error. The special character "&" in the hotel name was likely the cause of the issue.
Solution: To resolve the problem, I removed the special characters from the hotel name, resulting in "Hotel Yak Yeti." Then, I edited the "pb" parameter in the URL accordingly. This adjustment ensures that the URL is properly encoded and validated.
Original Google Embedded URL:

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14128.750188412732!2d85.3197981!3d27.7114951!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x39eb19042204f6a1%3A0xa7af95e7f7d75e66!2sHotel%20Yak%20%26%20Yeti!5e0!3m2!1sen!2snp!4v1690259560583!5m2!1sen!2snp" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
Enter fullscreen mode Exit fullscreen mode
Updated Embed URL:
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3532.187395792953!2d85.31518467397605!3d27.711499772684373!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x39eb19042204f6a1%3A0xa7af95e7f7d75e66!2sHotel%20Yak%20Yeti!5e0!3m2!1sen!2snp!4v1689753786090!5m2!1sen!2snp" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
Enter fullscreen mode Exit fullscreen mode

When saving this updated URL to the database, I used "Hotel%20Yak%20Yeti" to ensure proper URL encoding for the hotel name. This way, the embedded Google Maps location for "Hotel Yak Yeti" works seamlessly on my website.

Top comments (0)