首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

关于谷歌API,该怎么处理

2012-03-07 
关于谷歌API%@ Page LanguageC# AutoEventWireuptrueCodeFileDefault.aspx.cs Inherits_Defau

关于谷歌API
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
" http://www.w2.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps API Example - Google North America Offices</title>
<script src=" http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxQcTQoRJ_JVFHVwderj38GcfiXt6hQX5E6h3W3sV-l-QbtgIls1pN0iAw"
type="text/javascript"></script>
<script src="google_northamerica_offices.js" type="text/javascript"></script>
<script src="../src/markermanager.js"></script>
<script type="text/javascript">
//<![CDATA[
var map;
var mgr;
var icons = {};
var allmarkers = [];

function load() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GOverviewMapControl());
map.setCenter(new GLatLng(50, -98), 3);
map.enableDoubleClickZoom();
mgr = new MarkerManager(map, {trackMarkers:true});
window.setTimeout(setupOfficeMarkers, 0);
}
}

function getIcon(images) {
var icon = null;
if (images) {
if (icons[images[0]]) {
icon = icons[images[0]];
} else {
icon = new GIcon();
icon.image = "images/" 
+ images[0] + ".png";
var size = iconData[images[0]];
icon.iconSize = new GSize(size.width, size.height);
icon.iconAnchor = new GPoint(size.width >> 1, size.height >> 1);
icon.shadow = "images/" 
+ images[1] + ".png";
size = iconData[images[1]];
icon.shadowSize = new GSize(size.width, size.height);
icons[images[0]] = icon;
}
}
return icon;
}

function setupOfficeMarkers() {
allmarkers.length = 0;
for (var i in officeLayer) {
var layer = officeLayer[i];
var markers = [];
for (var j in layer["places"]) {
var place = layer["places"][j];
var icon = getIcon(place["icon"]);
var title = place["name"];
var posn = new GLatLng(place["posn"][0], place["posn"][1]);
var marker = createMarker(posn,title,icon); 
markers.push(marker);
allmarkers.push(marker);
}
mgr.addMarkers(markers, layer["zoom"][0], layer["zoom"][1]);
}
mgr.refresh();
}

function createMarker(posn, title, icon) {
var marker = new GMarker(posn, {title: title, icon: icon, draggable:true });
GEvent.addListener(marker, 'dblclick', function() { mgr.removeMarker(marker) } ); 
return marker;
}

function deleteMarker() {
var markerNum = parseInt(document.getElementById("markerNum").value);
mgr.removeMarker(allmarkers[markerNum]);
}

function clearMarkers() {
mgr.clearMarkers();
}

function reloadMarkers() {
setupOfficeMarkers();
}
//]]>
</script>

</head>
<body onload="load()" onunload="GUnload()">
<input type="button" onclick="deleteMarker()" value="delete marker #:" />

<input type="text" id="markerNum" value="0" size="3"/>
|
<input type="button" onclick="clearMarkers()" value="clear all markers" />
|
<input type="button" onclick="reloadMarkers()" value="reload all markers" />



<br/>
<div id="map" style="width: 600px; height: 400px;"></div>
</body>
</html>
这段代码运行的时候老是出错 里面的js脚本写的是什么

[解决办法]
网页错误详细信息

用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; AskTB5.6)
时间戳: Thu, 11 Nov 2010 05:27:12 UTC


消息: 无效字符
行: 1
字符: 1
代码: 0
URI: file:///C:/Documents%20and%20Settings/Administrator/桌面/google_northamerica_offices.js


消息: 无效字符
行: 1
字符: 1
代码: 0
URI: file:///C:/Documents%20and%20Settings/Administrator/src/markermanager.js


消息: 'MarkerManager' 未定义
行: 27
字符: 1
代码: 0
URI: file:///C:/Documents%20and%20Settings/Administrator/桌面/test.html


[解决办法]
mgr = new MarkerManager(map, {trackMarkers:true});
--这一行,什么问题,你看一看

热点排行