I am trying get a custom google map API in a website, bu the problem is the map in not showing full, only a part of the map is show.
Given below the code:
js code:
$(document).ready(function(){
var map=null;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(24.3573, 54.4636),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var currCenter = map.getCenter();
google.maps.event.trigger(map, 'resize');
map.setCenter(currCenter);
map.setZoom(14);
var markerOptions = {
position: new google.maps.LatLng(24.3573, 54.4636),
map: map
};
var marker = new google.maps.Marker(markerOptions);
marker.setMap(map);
var infoWindowOptions = {
content: '<b>Compnay Name</b><br> Is Here!'
};
var infoWindow = new google.maps.InfoWindow(infoWindowOptions);
infoWindow.open(map, marker);
};
google.maps.event.addDomListener(window, 'load', initialize);
});
html code:
<div class="container">
<h1>Location Map</h1>
<p></p>
<div id="map-canvas"></div>
</div>
css code:
.container {width: 100%; height: 100%;}
.container #map-canvas {
width: 500px;
height: 250px;
margin: 0;
border: 1px solid rgb(225, 225, 225);}
.map h2{
font-size: 16px;
font-weight: bold;
padding: 20px 0 6px 0;}
Pls let me know what am i doing wrong?
I have heard that 'google.maps.event.trigger(map, 'resize');' usually does the trick, but in my code it does not seems to work, maybe I am not place in the right place.. pls help.
Thank you.