I have created a page with a google map and it displays the general location but it is not centered around the marker. I have gone over several tutorial and the problem persist. I sized the #map container div both inline and on the style sheet and get the same results. I am using twitter bootstrap to style my page.
Here is my HTML/JS
...
<div class="col-sm-6">
<div id="map" style="height:300px">
</div>
</div>
...
<script>
var map;
function initMap() {
var mapOptions = {
center: new google.maps.LatLng(31.7717067, -106.3308777),
zoom: 15,
mapTypeId: 'roadmap'
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
addMarker();
}
</script>
<script>
function addMarker(){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(31.7717067, -106.3308777),
map: map
});
</script>
My CSS
#map {
height: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
}
2
Answers
I hacked the view and used the panTo method. Not sure if this is the correct thing to do but I got the view needed.
You can have it all in one function
For CSS try this: