Я столкнулся с проблемой на картах Google, я использую google api V3 и используя несколько карт на странице, все карты прекрасно работают на отдельной странице, но когда я использую на своем веб-сайте, это выглядит изображение нижеgoogle map неправильно работает
на самом деле карта по умолчанию скрываются, когда пользователь нажимает на ссылку дополнительная информация, то карты скользят вниз (с помощью slideToggle());
$(document).ready(function() {
$maps = $('.map_canvas');
$maps.each(function(index, Element) {
$infotext = $(Element).children('.infotext');
var myOptions = {
'zoom': parseInt($infotext.children('.zoom').text()),
'mapTypeId': google.maps.MapTypeId.ROADMAP
};
var map;
var geocoder;
var marker;
var infowindow;
var address = $infotext.children('.address').text() + ', '
+ $infotext.children('.city').text() + ', '
+ $infotext.children('.state').text() + ' '
+ $infotext.children('.zip').text() + ', '
+ $infotext.children('.country').text()
;
var content = '<strong>' + $infotext.children('.location').text() + '</strong><br />'
+ $infotext.children('.address').text() + '<br />'
+ $infotext.children('.city').text() + ', '
+ $infotext.children('.state').text() + ' '
+ $infotext.children('.zip').text()
;
if (0 < $infotext.children('.phone').text().length) {
content += '<br />' + $infotext.children('.phone').text();
}
geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
myOptions.center = results[0].geometry.location;
map = new google.maps.Map(Element, myOptions);
marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
title: $infotext.children('.location').text()
});
infowindow = new google.maps.InfoWindow({'content': content});
google.maps.event.addListener(map, 'tilesloaded', function(event) {
infowindow.open(map, marker);
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
} else {
alert('The address could not be found for the following reason: ' + status);
}
});
});
});
здесь HTML markeup но данные в дивы идет динамически из базы данных
<div class="map_canvas">
<div class="infotext">
<div class="location">Chácara do João</div>
<div class="address">Av andrade neves, 2333</div>
<div class="city">Campinas</div>
<div class="state">SP</div>
<div class="zip">33401-3995</div>
<div class="country">USA</div>
<div class="phone">(561) 659-4050</div>
<div class="zoom">1</div>
</div>
</div>
благодаря @benjaminbenben, но он не работает для меня, до сих пор такая же проблема, и она не тянет карту, примечание: перетаскивание проблему также до вашего решения, не думаю, это после вашей помощи –
спасибо! но мне это не помогло –
Хм, странно. Возможно, это нечто внешнее. Вот ваш код в скрипке, когда он скользит один раз без изменения размера (показывая проблему), а затем вызывает изменение размера - http://jsfiddle.net/R73s2/ – benjaminbenben