I have implemented Google maps in my app (in a modal), however as you can see on the images below there is a grey area that I of course want to get rid of. It is possible to move the map so that the grey area disappears, but that shouldn't be needed.
Thing is that the map is shown inside a modal box, which contains of a lot of content that's dynamically created when the button for showing the modal is clicked. It seems that the problem could be that the map content isn't fully loaded before the modal is loaded, but I'm not sure...
html:
...
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Test</h3>
</div>
<div id="modal-left" class="modal-body left"></div>
<div class="modal-body right">
<div id="map"></div>
</div>
</div>
...
js:
function initializeMap(latitude, longitude) {
var place = new google.maps.LatLng (latitude, longitude);
var myOptions = {
zoom: 10,
center: place,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map"), myOptions);
var marker = new google.maps.Marker({
position: place,
map: map,
title: ""
});
};
$('.modal-btn').click(function(){
var producerId = $(this).attr('id');
GetProducer(producerId, function(data) { // <--- data retrieved through ajax
initializeMap(data.latitude, data.longitude);
var titel = data.name;
var content = "<p><img class='modal-img' src='" + data.imgurl + "' /></p>" +
"<p>" + data.name + ", " + data.address + "<br/>" +
data.zipcode + " " + data.town + "</p>" +
"<p><a href='" + data.url + "' >" + data.url + "</a></p>";
$('#myModalLabel').html(titel);
$('#modal-left').html(content);
});
});
Image 1:
Image 2:
Sometimes when you scroll across a Google Map screen you'll see blocks of grey. Usually this occurs when the map is set to satellite view and the application struggles to load the data fast enough. However, sometimes this phenomenon occurs in map view if Google doesn't have access to the right data.
On some maps, post offices, churches, city halls, and other landmark buildings are shown within the tinted area. The first features usually noticed on a topographic map are the area features, such as vegetation (green), water (blue), and densely built-up areas (gray or red).
As you explore the new map, you'll notice areas shaded in orange representing “areas of interest”—places where there's a lot of activities and things to do. To find an “area of interest” just open Google Maps and look around you.
All replies. the greyed out location is because the location is an old or outdated location and is not being refeshed anymore. this is because the person who shared the location with you either turned off their phone or manually stopped sharing their location with you.
The usual reason why this is happening is that the size of the map is changed after the map has been initialized. If you for some reason change the size of the div with id="map" you need to trigger the "resize" event
google.maps.event.trigger(map, 'resize');
You could just try to trigger the event in your javascript console and see if it helps.
Please note that this answer is a guess since there is not really anything in the question to work with, so please let me know if it does not help.
Put google.maps.event.trigger(map, "resize"); in a setTimeout function so that it fires AFTER the event is triggered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With