【发布时间】:2014-10-14 22:09:35
【问题描述】:
我正在使用 jquery.ui.maps 并从 json 填充标记。使用下面的代码,我看到了标记应该在的标签,但我在页面上只看到一个标记。如果我注释掉'marker': MarkerWithLabel,那么我会看到所有标记,但没有标签。我需要做什么才能看到标签和标记?
$.each( result, function(i,marker) {
$('#map_canvas').gmap('addMarker', {
'id': i,
'bounds': true,
'marker': MarkerWithLabel,
'labelContent': '<a class="hint--top hint--always" data-hint="'+this.price+'">'+this.price+'</a>',
'labelAnchor': new google.maps.Point(6, 10),
'labelClass': "labels",
'labelStyle': {opacity: 0.75},
'labelInBackground': false,
'position': new google.maps.LatLng(marker.latitude, marker.longitude)
}).click(function() {
$('#map_canvas').gmap('openInfoWindow', { 'content': marker.street_address_full }, this);
});
});
【问题讨论】:
-
请使用 www.jsfiddle.net 向我们展示您已经拥有的东西。
-
我创建了一个 jsfiddle 但我不熟悉它,我无法让最初来自 php 的 json 数据工作。 jsfiddle.net/2qcbb3rj/9
-
听起来issue with MarkerWithLabel是你的地图使用的吗?看起来可能是 ('marker': MarkerWithLabel)
-
你的小提琴的 JSON 有问题。如果我使用最新版本的 markerwithlabel,并为 JSON 问题添加错误处理,it works for me。
标签: javascript jquery google-maps google-maps-api-3