我在使用 OpenLayers 时遇到问题。我的工作代码是:
<html><body>
<div id="mapdiv"></div>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script>
map = new OpenLayers.Map("mapdiv");
map.addLayer(new OpenLayers.Layer.OSM());
//var results = new OpenLayers.Layer.Text("My Points", { location:"./checkIns_0_view.txt", projection: map.displayProjection});
//map.addLayer(results);
var query = new OpenLayers.LonLat(-122.2928337167, 37.5549570333).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
var markers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(markers);
var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('http://openlayers.org/dev/img/marker-blue.png', size, offset);
marker = new OpenLayers.Marker(query, icon);
markers.addMarker(marker);
var zoom=16;
map.setCenter (query, zoom);
</script>
</body></html>
现在我想添加一个包含一些信息的弹出窗口。我尝试使用几个示例,例如http://openlayers.org/dev/examples/osm-marker-popup.html。我想添加这样的东西:
var popup = new OpenLayers.Popup.FramedCloud("Popup", query, null, "Text", true);
map.addPopup(popup);
第一行可以编译,但是当我添加第二行时,浏览器不显示我的地图。我认为这可能与查询 lonLat 有关,但我没有必要的 OpenLayers 技能来找出答案。
我非常感谢您的回答。
问候