簡體   English   中英

標記與谷歌地圖api中的圖像和數字

[英]Marker with image and number in google maps api

我正在使用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);
    });
}

和圖標是

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 
        );

使用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
 });

在此輸入圖像描述

http://jsfiddle.net/Vug7W/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM