我已经实现了谷歌地图事件触发器。但是,似乎没有触发/调用任何事件。所以我在代码上方添加了函数初始化,因为 glob var 位于另一个文件中。但是,出现了新问题,标签消失了。
几个问题:1)是否正确添加了全局变量?2)我是否必须将 google.maps.event 添加到选项卡构造函数中?3)我尝试了很多,但地图似乎仍然坏了。有什么解决方案吗?
?>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript">
var map;
function initialize() {
var latLng = new google.maps.LatLng(<?php echo $geo_latitude;?>, <?php echo $geo_longitude;?>);
Demo.map = new google.maps.Map(Demo.mapContainer, {
<?php
if(get_option('ptthemes_scale_factor')){
$ptthemes_scale_factor = get_option('ptthemes_scale_factor');
} else {
$ptthemes_scale_factor = 13;
}
?>
zoom: <?php echo $ptthemes_scale_factor;?>,
center: latLng,
<?php
if($map_type=='Road Map' || $map_type=='Satellite Map'|| $map_type=='Terrain Map'){
if($map_type=='Satellite Map') {
$map_type = SATELLITE;
} elseif($map_type=='Terrain Map') {
$map_type = TERRAIN;
} else {
$map_type = ROADMAP;
}
?>
mapTypeId: google.maps.MapTypeId.<?php echo $map_type;?>
<?php
} else {
?>
mapTypeId: google.maps.MapTypeId.ROADMAP
<?php
}
?>
});
var marker = new google.maps.Marker({
position: latLng,
map: Demo.map,
title:"<?php echo trim($post->post_title);?>"
});
jQuery.noConflict();
jQuery(document).ready(function($) {
jQuery("#tabs").tabs();
});
$(function() {
$("#tabs").tabs({
activate: function(e, ui) {
google.maps.event.trigger(Demo.map, "resize");
}
});
});
}
</script>
全局变量在这里定义:
init: function() {
var latLng = new google.maps.LatLng(<?php echo $geo_latitude;?>, <?php echo $geo_longitude;?>);
Demo.map = new google.maps.Map(Demo.mapContainer, {
<?php
if(get_option('ptthemes_scale_factor')) {
$ptthemes_scale_factor = get_option('ptthemes_scale_factor');}
else {
$ptthemes_scale_factor = 13;
}
?>
zoom: <?php echo $ptthemes_scale_factor;?>,
center: latLng,
<?php
if($map_type=='Road Map' || $map_type=='Satellite Map'|| $map_type=='Terrain Map'){
if($map_type=='Satellite Map') {
$map_type = SATELLITE;
} elseif($map_type=='Terrain Map') {
$map_type = TERRAIN;
} else {
$map_type = ROADMAP;
} ?>
mapTypeId: google.maps.MapTypeId.<?php echo $map_type;?>
<?php
} else {
?>
mapTypeId: google.maps.MapTypeId.ROADMAP
<?php
}
?>
});
var marker = new google.maps.Marker({
position: latLng,
map: Demo.map,
title:"<?php echo trim($post->post_title);?>"
});
}