我认为这是一个棘手的问题,但希望有人可以阻止我撕掉我的头发!
我目前正在尝试弄清楚如何在谷歌地图上覆盖一堆标记,并覆盖托管的tileJson图层。
我也尝试按照本教程进行操作,以便在用户点击任何地图点时将图片和文字加载到侧边栏中:
本教程是为地图api2设计的(我使用的是3)虽然看起来很容易为api 3更新。
现在,部分原因是因为javascript连接器简化了导入自定义磁贴的工作,我似乎无法使标记工作,更不用说将它们连接到数据库,并从地图窗口外部访问它们。
https://mywebspace.wisc.edu/axler/Web%20Deep%20Map/Web%20Map%20Google%20Maps/index2.html 实时地图图块...在上面的链接。没有任何一点工作,但我在代码的列表中放了一些样本点。
有什么建议吗?这是我的代码。
<html>
<head>
<title>GOOGLE MAPS TILEMILL</title>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyD6VG2UbuMLDCQoZ-GOPZl_PU7r1jXzejU&sensor=false">
</script>
<script
src='wax/dist/wax.g.min.js'
type='text/javascript'></script>
<link href='wax/theme/controls.css' rel='stylesheet' type='text/css' />
<link href='style.css' rel = 'stylesheet' type ='text/css' />
<link href='controls.css' rel = 'stylesheet' type = 'text/css' /><script>
var map;
var sidebar;
function pageLoad() {
sidebar = document.getElementById('sidebar');
addPoint(1, 'Howards Fish House', 46.72.30616121527788, -92.15);
addPoint(2, 'Rices Point', 46.78, -92.18);
addPoint(3, 'Wild Rice Seeding Area', 46.80, -92.22);
wax.tilejson('http://a.tiles.mapbox.com/v3/slre.st-louis-river-estuary.jsonp',
function(tilejson) {
var map = new google.maps.Map(
document.getElementById('mymap'), {
center: new google.maps.LatLng(46.72, -92.15),
disableDefaultUI: false,
zoom: 12,
panControl: false,
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.TOP_RIGHT
},
scaleControl: true,
streetViewControl: false,
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP });
// Use this code to set a new layer as a baselayer -
// which means that it'll be on the bottom of any other
// layers and you won't see Google tiles
map.mapTypes.set('mb', new wax.g.connector(tilejson));
map.setMapTypeId('mb');
//I want to place a number of points on top of the MapBox hosted tile layer that is specified by wax.tilejson
});
}
function addPoint(pid, name, lat, lng) {
var point = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker(point);
map.setMap(marker);
var info = '<strong>' + name + '</strong><br />';
info += 'For more information, click the icon.';
google.maps.event.addListener(marker, 'mouseover', function() {
marker.openInfoWindow(info);
});
google.maps.event.addListener(marker, 'mouseout', function() {
map.closeInfoWindow();
});
google.maps.event.addListener(marker, 'click', function() {
details.innerHTML = '<em>Loading information ...</em>';
showDivInfo(pid);
});
}
</script>
</head>
<body onload="pageLoad()" onunload="pageUnload()">
<div id='sidebar'>
<h2>Explore the St. Louis River Estuary</h2>
<p>Click on the map points to learn about the stories and science that define the region!</p>
<p><span class='source'>Source: <a href='http://www.stlre.pebbleonline.com'>Main Web Page</a></span></p>
</div>
<div id='mymap'></div>
</body>
</html>
答案 0 :(得分:0)
这个map.setMap(标记);看起来不对劲
应该是
marker.setMap(map);
:)