【发布时间】:2011-10-13 13:49:50
【问题描述】:
我正在尝试在锚点点击时加载谷歌地图。以下是详细信息。
我有 index.aspx 页面,其中有一个锚标记和一个 div "divLoadMap"
<a class="loadMap" href="map.aspx">Load Map</a>
<div id="divLoadMap">
</div>
我有 map.aspx,其中包含地图详细信息。下面是代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="_LANGUAGE" xml:lang="_LANGUAGE">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Jquery CSS Tabs and V3 Google Maps</title>
<script type="text/javascript" src="/common/js/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
function initialize()
{
var latlng = new google.maps.LatLng(25.294371, 55.332642);
var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: 'Dubai'
});
var contentString = 'Dubai';
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 50
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
}
initialize();
});
</script>
</head>
<body>
<form id="mapform" >
<div id="map_canvas" style="width: 500px; height: 500px">
</div>
</form>
</body>
</html>
现在我想通过单击 index.aspx 上的锚标记来加载此地图。
请推荐!!如果能获得上述问题的代码示例,将不胜感激。
【问题讨论】:
-
您的问题不清楚 - 如果您单击锚点,您将被带到 map.aspx,该文件将加载到地图中。你能说得更具体点吗?
-
在锚点上,它将在覆盖窗口中打开 map.aspx,即在同一页面上打开灯箱。
标签: jquery html google-maps google-maps-api-3