Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a google map to use 100% of its parent container?

I have tried to do this in many different ways but the most obvious was this:

var map2 = new GMap2(document.getElementById("map2"), {size:"100%"});

That does not work.

like image 518
Artilheiro Avatar asked Jul 29 '09 00:07

Artilheiro


People also ask

Is Google Maps API free for commercial use?

You won't be charged until your usage exceeds $200 in a month. Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).

Can you customize Google Maps API?

Easily create your styleThe new Google Maps APIs Styling Wizard helps you to create a map style in a few clicks. Use one of our pre-built styles or create your own style from scratch.

What is the daily limit for Google Maps API?

While there is no maximum number of requests per day, the following usage limits are in place for the Maps JavaScript API: 30,000 requests per minute. 300 requests per minute per IP address. In the Google Cloud Console, this quota is referred to as Map loads per minute per user.


1 Answers

Google says:

Unless you specify a size explicitly for the map using GMapOptions in the constructor, the map implicitly uses the size of the container to size itself.

So set the size of your map container fill all available space:

<div id="map2" style="width: 100%; height: 100%"></div>
like image 153
Keltex Avatar answered Oct 05 '22 23:10

Keltex