[英]Marker with image and number in google maps api
I am using gmap .. I want to put some marker on the map the marker icon is dynamic, I also want a "Number" to be display with the Icon , Is this possible.. My Code is 我正在使用gmap ..我想在地图上放置一些标记,标记图标是动态的,我还想要一个“数字”来显示图标,这是可能的..我的代码是
function putMaker(position, title, title_dis, number, icon_img)
{
if (!isNaN(number))
var icon = "https://chart.googleapis.com/chart?chst=d_bubble_icon_text_small&chld=ski|bb|" + number + "|FFFFFF|000000";
else
var icon = null;
var marker = new google.maps.Marker({
position: position,
map: map,
icon: icon_img,
shadow: icon,
});
google.maps.event.addListener(marker, 'mouseover', function() {
infowindow.setContent(title_dis);
infowindow.open(map, this);
});
}
And Icon is 和图标是
var icon_img = new google.maps.MarkerImage(
"<?php echo base_url().'timthumb.php?src='.$url.'&h=32&w=50'; ?>", //url
new google.maps.Size(50, 32), //size
new google.maps.Point(0, 0), //origin
new google.maps.Point(0, 32) //anchor
);
It is perfectly possible using the markerwithlabel library . 使用markerwithlabel库是完全有可能的。 You can modify one of the basic examples by adding the
icon
parameter (you can add there any of the standard google.maps.Marker
options ): 您可以通过添加
icon
参数来修改其中一个基本示例 (可以在其中添加任何标准google.maps.Marker
选项 ):
var marker = new MarkerWithLabel({
position: homeLatLng,
map: map,
draggable: true,
raiseOnDrag: true,
labelContent: "2", // your number
icon: "img/your_icon.png",
labelAnchor: new google.maps.Point(3, 30),
labelClass: "labels", // the CSS class for the label
labelInBackground: false
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.