0
我在获取选项卡式信息窗口以显示路径时遇到一些困难。我跟着this tutorial。Google Maps API v3多段线选项卡InfoWindow
我有一个带多段线的KML图层(它们曲线 - 代表地形特征) 并且不知道如何在单击路径时显示信息窗口。我已经看到了计算中点(但直线)一些教程..
2种方式(很多)我一直试图让路径指向:
var streamPoly = google.maps.Polyline.prototype.getPosition = function() {
return this.getPath().getAt(0);}
var streamPoly = poly.getPath();
是什么在我的头:
var map;
var streamPoly;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(42.687984,-79.394159);
var mapOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var ctaLayer = new google.maps.KmlLayer({
url: 'paths.kml'
});
ctaLayer.setMap(map);
ctaLayer.set('preserveViewport', true);
var infoBubble = new InfoBubble({
maxWidth: 300
});
var div = document.createElement('DIV');
div.innerHTML = 'Hello';
infoBubble.addTab('Tab 1', div);
infoBubble.addTab('Tab 2', "<B>This is tab 2</B>");
google.maps.event.addListener(streamPoly, 'click', function() {
if (!infoBubble.isOpen()) {
infoBubble.open(map, streamPoly);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
我试着使用KmlMouseEvent属性(featureData,latLng)进行事件,但某些内容仍然不起作用。这可能是标签,但不知道如何解决这个问题。理想情况下,希望让标签式信息泡沫起作用! – user2309395 2013-04-25 04:52:45
提供一个链接到您的KML,我可能会提供一个例子。 – geocodezip 2013-04-25 16:33:01
这里是KML:http://tinyurl.com/co6efw8 – user2309395 2013-04-25 17:57:41