Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/479.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 标记上的标签不';行不通_Javascript_Google Maps_Google Maps Api 3_Maps_Google Maps Markers - Fatal编程技术网

Javascript 标记上的标签不';行不通

Javascript 标记上的标签不';行不通,javascript,google-maps,google-maps-api-3,maps,google-maps-markers,Javascript,Google Maps,Google Maps Api 3,Maps,Google Maps Markers,我遵循了一些指南,但标签并没有显示在我的地图上。 我用离子。 这是我的代码(在地图控制器中): 这是css: .labels { color: red; background-color: white; font-family: "Lucida Grande", "Arial", sans-serif; font-size: 10px; font-weight: bold; text-align: center; width: 40px; border: 2px sol

我遵循了一些指南,但标签并没有显示在我的地图上。 我用离子。 这是我的代码(在地图控制器中):

这是css:

.labels {
 color: red;
 background-color: white;
 font-family: "Lucida Grande", "Arial", sans-serif;
 font-size: 10px;
 font-weight: bold;
 text-align: center;
 width: 40px;     
 border: 2px solid black;
 white-space: nowrap;
}

标记已在地图上正确查看,但未显示其标签。

代码看起来像是-库的示例

您必须包含并创建一个
新标记WithLabel
,而不是
新的google.maps.Marker

var mylatng=new google.maps.LatLng(0,0);
var stylesMap=[{
特征类型:“poi”,
elementType:“标签”,
样式:[{
能见度:“关闭”
}]
}];
变量myOptions={
缩放:15,
中心:myLatLng,
mapTypeId:google.maps.mapTypeId.ROADMAP,
街景控制:错误,
mapTypeControl:false,
样式:样式映射
};
var map=new google.maps.map(document.getElementById(“gmaps画布”),myOptions);
变量标记=新标记WithLabel({
职位:myLatLng,
地图:地图,
标签内容:“42.5万美元”,
labelAnchor:新的google.maps.Point(22,0),
labelClass:“labels”,//标签的CSS类
zIndex:10000
//,图标:“img/marker/tuseiqui.png”
});
google.maps.event.addListener(标记'click',function(){})
html,
身体,
#gmaps帆布{
身高:100%;
填充:0;
保证金:0;
}
.标签{
颜色:红色;
背景色:白色;
字体系列:“Lucida Grande”,“Arial”,无衬线;
字体大小:10px;
字体大小:粗体;
文本对齐:居中;
宽度:40px;
边框:2件纯黑;
空白:nowrap;
}


谢谢!工作顺利!:)对不起,我可以使用更多不同宽度的标签并将其居中标记吗?以及其他问题。。单击更多标记不起作用。。我添加了它:google.maps.event.addListener(marker,'click',(函数(marker,I){return function(){$scope.setInfoWindow(data[I].id);}})(marker,I));我不熟悉爱奥尼亚/安格拉斯。请根据您当前的实现创建一个fiddle,我来看看。我认为angularjs没有问题。对于代码,标签单击有效,但标记单击无效。我很快就会拉小提琴。
.labels {
 color: red;
 background-color: white;
 font-family: "Lucida Grande", "Arial", sans-serif;
 font-size: 10px;
 font-weight: bold;
 text-align: center;
 width: 40px;     
 border: 2px solid black;
 white-space: nowrap;
}