I'm using the code below to display a Google Map on modal pop-up. But the Google Map marker is not displayed at the center of the modal. It's always hidden at the left corner.
<script>
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(0.0, 0.0);
var mapOptions = {
zoom: 14,
center: new google.maps.LatLng(0.0, 0.0),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
}
function codeAddress(i) {
var address = document.getElementById('address'+i).value;
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
zoom:10,
position: results[0].geometry.location
});
google.maps.event.addListenerOnce(map, 'idle', function () {
google.maps.event.trigger(map, 'resize');
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
Also see the code here