带有标签的Google地图V3标记 [英] Google Maps V3 marker with label
问题描述
map.gmap()如何将标签添加到我的标记中如果我的标记在ajax成功填充每个结果。 'addMarker',{'position':new google.maps.LatLng(result.latitude,result.longitude)});
我试过这样,但没有成功:
map.gmap('addMarker',{
'position':new google.maps.LatLng(result.latitude,result.longitude),
'bounds':true,
'icon':markerIcon,$ b $'labelContent':'A',
'labelAnchor':new google.maps.Point(result.latitude,result.longitude ),
'labelClass':'labels',//标签的CSS类
'labelInBackground':false
});
我怀疑标准库支持这一点。
但您可以使用Google地图实用程序库: b
http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries#MarkerWithLabel
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom:8,
center:myLatlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),myOptions);
var marker = new MarkerWithLabel({
position:myLatlng,$ b $ map:map,
draggable:true,
raiseOnDrag:true,
labelContent:A,
labelAnchor:新的google.maps.Point(3,30),
labelClass:labels,//标签的CSS类
labelInBackground:false
});
关于标记的基本知识可以在这里找到: https://developers.google.com/maps/documentation/javascript/overlays#Markers
How can I add label to my marker if my markers are populated on ajax success each result.
map.gmap('addMarker', { 'position': new google.maps.LatLng(result.latitude, result.longitude) });
I tried like this, but with no success:
map.gmap('addMarker', {
'position': new google.maps.LatLng(result.latitude, result.longitude),
'bounds': true,
'icon': markerIcon,
'labelContent': 'A',
'labelAnchor': new google.maps.Point(result.latitude, result.longitude),
'labelClass': 'labels', // the CSS class for the label
'labelInBackground': false
});
I doubt the standard library supports this.
But you can use the google maps utility library:
http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries#MarkerWithLabel
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
var marker = new MarkerWithLabel({
position: myLatlng,
map: map,
draggable: true,
raiseOnDrag: true,
labelContent: "A",
labelAnchor: new google.maps.Point(3, 30),
labelClass: "labels", // the CSS class for the label
labelInBackground: false
});
The basics about marker can be found here: https://developers.google.com/maps/documentation/javascript/overlays#Markers
这篇关于带有标签的Google地图V3标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!