标记与谷歌地图api中的图像和数字

Nit*_*Dev 2 javascript php google-maps google-maps-api-3

我正在使用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);
    });
}
Run Code Online (Sandbox Code Playgroud)

和图标是

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 
        );
Run Code Online (Sandbox Code Playgroud)

TMS*_*TMS 7

使用markerwithlabel库是完全可能的.您可以通过添加参数来修改其中一个基本示例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
 });
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

http://jsfiddle.net/Vug7W/