gpt4 book ai didi

导致 PIE.htc 错误的 Javascript/Google map

转载 作者:搜寻专家 更新时间:2023-11-01 04:19:37 26 4
gpt4 key购买 nike

全部,我有以下代码:

<script type="text/javascript">
function Store( lat, long, text )
{
this.latitude = lat;
this.longitude = long;
this.html = text;
}

var myStores = [<?php echo $jsData;?>, null];
addLoadEvent(loadMap);

这里填充了以下代码:

$lat = $post->latitude;
$long = $post->longitude;
$post_id = $post->ID;
$get_post_info = get_post($post_id);
$name = $get_post_info->post_title;
$jsData = $jsData . "new Store( $lat, $long, '$name' ),\n";

我的页面在没有 javascript 部分的情况下加载正常。但是,当我添加 javascript 时,出现以下错误:

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8; AskTbAD2/5.14.1.20007)Timestamp: Wed, 22 Feb 2012 16:45:35 UTCMessage: Arg: Illegal input string in Vector2DLine: 68Char: 63Code: 0URI: http://localhost/wordpress/wp-content/themes/parallelus-mingle/assets/css/PIE.htc

I actually narrowed it down even further and this line is the one causing the error:

addLoadEvent(loadMap);

这是 addLoadEvent(loadMap) 的完整代码:

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript">
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func
} else {
window.onload = function() {
oldonload();
func();
}
}
}

var map,
infowin=new google.maps.InfoWindow({content:'moin'});
function loadMap()
{
map = new google.maps.Map(
document.getElementById('map'),
{
zoom: 12,
mapTypeId:google.maps.MapTypeId.ROADMAP,
center:new google.maps.LatLng(<?php echo $_SESSION['pav_event_latitude']; ?>,
<?php echo $_SESSION['pav_event_longitude']; ?>)
});

addPoints(myStores);
}

function addPoints( points )
{
var bounds=new google.maps.LatLngBounds();
for ( var p = 0; p < points.length; ++p )
{
var pointData = points[p];
if ( pointData == null ) {map.fitBounds(bounds);return; }
var point = new google.maps.LatLng( pointData.latitude, pointData.longitude );
bounds.union(new google.maps.LatLngBounds(point));
createMarker( point, pointData.html );
}
map.fitBounds(bounds);

}

var number = 2; // or whatever you want to do here
function createMarker(point, popuphtml)
{
var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
var marker = new google.maps.Marker(
{
position:point,
map:map,
icon:'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld='+number+'|FF776B|000000',
shadow:'https://chart.googleapis.com/chart?chst=d_map_pin_shadow'
}
);
google.maps.event.addListener(marker, 'click', function() {
infowin.setContent(popuphtml)
infowin.open(map,marker);
});

}
</script>

知道为什么这会导致错误吗?

最佳答案

您的 addLoadEvent() 似乎没有正常工作,并且正在将 loadMap() 的空参数列表发送到 PIE.htc onload 事件方法。另外,我相信函数的 typeof 实际上会返回 object 而不是 function。无论哪种方式,请尝试删除它来代替您的函数:

function addLoadEvent(func) { 
if (window.addEventListener) {
window.addEventListener('load', func, false);
} else if(window.attachEvent) {
window.attachEvent('onload', func);
}
}

另一个确保它适用于所有浏览器的选项是使用 jQuery 的 $(document).ready(), domReady ,或其他一些等价物。

编辑:此外,这一行:

var myStores = [<?php echo $jsData;?>, null];

将在 null 之前以两个逗号结束,除非您在原始问题中遗漏了一些 PHP 代码。

关于导致 PIE.htc 错误的 Javascript/Google map ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9434611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com