Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Responsive Google Map?

How to make a responsive google map from the code

<div class="map">     <iframe>...</iframe> </div> 

I use in css for full map

.map{max-width:100%;} 

and small device

.map{max-width:40%;} 

but it didn't work.

Anyone have idea? Thank you.

like image 385
Lena Queen Avatar asked Mar 14 '13 22:03

Lena Queen


People also ask

Is Google Maps API no longer free?

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).


1 Answers

Add this to your initialize function:

<script type="text/javascript">  function initialize() {    var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);    // Resize stuff...   google.maps.event.addDomListener(window, "resize", function() {     var center = map.getCenter();     google.maps.event.trigger(map, "resize");     map.setCenter(center);    });  }  </script> 
like image 105
missmonkee Avatar answered Sep 24 '22 10:09

missmonkee