Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7402119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:39:52+00:00 2026-05-29T04:39:52+00:00

I have this weird problem where my Google Maps API script doesn’t work, no

  • 0

I have this weird problem where my Google Maps API script doesn’t work, no map is rendered, when I declare a DOCTYPE.

Without a DOCTYPE I get the following warning, but it works and a map is rendered:

Resource interpreted as Other but transferred with MIME type undefined.

I have no real clue to what is wrong, but I hope some wiz here might!

Here you can see the script in action without DOCTYPE:
[LINK REMOVED SINCE QUESTION IS ANSWERED]

…and here it is with DOCTYPE declared as HTML5:
[LINK REMOVED SINCE QUESTION IS ANSWERED]

JavaScript source is pretty long, but you can find it here:
[LINK REMOVED SINCE QUESTION IS ANSWERED]
But I’ve made it publicly available at http://snipt.org/yZgm2 if anyone care!

Thank you for your time!

UPDATE 1:

So, it seems like my JavaScript wasn’t the problem. But the div-element had no height or width to begin with, and for some reason it works different with or without DOCTYPE.

So new question!

Why does the following code part not work when I have declared a DOCTYPE?

var mapElement = document.getElementById(mapOptions['mapid']);
mapElement.style.width=mapOptions['width'];
mapElement.style.height=mapOptions['height'];

UPDATE 2:

Thanks to both @fivedigit and @duncan for pointing out the CSS problem. Simply adding the measurement unit solved it all!

mapElement.style.width=mapOptions['width']+'px';
mapElement.style.height=mapOptions['height']+'px';
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:39:54+00:00Added an answer on May 29, 2026 at 4:39 am

    The difference is that the doctype declaration makes the browser go into standard mode, rather than quirks mode. And that’s where a little bug in your JavaScript acts up.

    The map is created in both instances, but when the doctype has been declared, the map’s height is 0, and the width is set to its default (100%).

    You have this bit of code where you set the width and height of the map:

    if(mapOptions['width'] !== false){
        mapElement.style.width=mapOptions['width'];
    }
    if(mapOptions['height'] !== false){
        mapElement.style.height=mapOptions['height'];
    }
    

    You forgot to specify the unit there, and in standards mode, that style rule will then be dropped. Change the code to this to make it work:

    if(mapOptions['width'] !== false){
        mapElement.style.width=mapOptions['width'] + 'px';
    }
    if(mapOptions['height'] !== false){
        mapElement.style.height=mapOptions['height'] + 'px';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have this weird problem with Google Maps V3 API. Showing multiple markers
I'm having this problem: I have two Google maps in one page, showing just
I have this weird problem with setting up cookies with PHP. Everything worked fine
This is a weird problem I have started having recently. My team is developing
This is a really weird problem that I have been having. When I download
I have a weird problem, and I don't know if this is the default
This is kind of a weird problem, but I have to create a search
I have weird problem, i've placed an google ads on my page and it
This is a really weird problem: I have set up the authlogic_openid_selector_example app .
I'm implementing Google Maps service with PHP/CURL and currently have a problem with Maps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.