Add numbering label to google map marker

孤人 提交于 2019-12-18 12:44:13

问题


May I know how to add numbering label to google map marker using google map api? Just add label, not trying to change the icon. Thank you.


回答1:


If you don't want to use custom icons for each marker then I suggest looking into creating a label class with the OverlayView and then binding the position to the marker.

Or you could look at using something like: http://github.com/nmccready/google-maps-utility-library-v3-infobox




回答2:


I think a better solution is to use a infoWindow. Something like this:

$(document).ready(function () {
    var golfoMexico = new google.maps.LatLng(20.61536,-87.078975);
    var settings = {
        zoom: 18,
        center: golfoMexico,
        mapTypeControl: true,
        mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
        navigationControl: true,
        navigationControlOptions: {style: google.maps.NavigationControlStyle.ZOOM_PAN},
        mapTypeId: google.maps.MapTypeId.HYBRID
    };

    var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
    var pos1= new google.maps.LatLng(20.61536,-87.078975);
     var infowindow = new google.maps.InfoWindow({
           content: "Casa Stavola F8 II"
         });
    var companyMarker = new google.maps.Marker({ position: pos1, map: map,title:"Casa Stavola F8 II", visible:true});
    infowindow.open(map,companyMarker);
});



回答3:


Check out the example at http://www.geocodezip.com/basic8j.asp?filename=example_number.xml (for V2 of the API). There was also a question here about something similar - How can I create numbered map markers in Google Maps V3?.



来源:https://stackoverflow.com/questions/3562506/add-numbering-label-to-google-map-marker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!