【发布时间】:2015-04-29 06:52:01
【问题描述】:
今天我看到一个关于在同一个按钮中打开/关闭的答案,我决定尝试使用。
我想要的是点击标记,然后一个信息窗口出现在我的地图中,但它不起作用。
JSFiddle simple marker with infowindow
JSFiddle toogle on/off but no infowindow
当我尝试像这样加入(使用 infowindow 工具)时:
google.maps.event.addDomListener(buttonCarrosUI, 'click', function() {
if(marker && marker.setMap){
if (marker.getMap() != null)
marker.setMap(null);
else marker.setMap(map_canvas);
}else{
var myLatLng;
var title = marker.title;
$.each( data.markers, function(i, marker) {
myLatLng = new google.maps.LatLng(marker.latitude, marker.longitude);
});
var infowindow = new google.maps.InfoWindow({
content: title,
});
marker = new google.maps.Marker({
position: myLatLng,
map: map_canvas,
icon: image,
title: title
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map_canvas,marker);
});
}
});
我遇到了这个问题
TypeError:标记未定义
var title = marker.title;
如果有人可以帮助我,我将非常感激,谢谢。
【问题讨论】:
-
产生该错误的代码在哪里?
-
错误是当我尝试加入两个代码时,如灰色部分
-
那有一个不同的错误:
Uncaught SyntaxError: Unexpected end of input -
Firebug 告诉我标记未定义大声笑
标签: javascript jquery google-maps google-maps-api-3