Using a custom image marker on google static map?

前端 未结 3 1597
轮回少年
轮回少年 2021-02-02 09:29

how to have custom image marker on google static map, i need url format:

this is what i have tried, but its having default marker image http://maps.google.com/maps/a

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 10:12

    You can add an image in the marker:

    var campaign_map = new google.maps.Map(document.getElementById("campaign_map_canvas"), mapOptions);
    
    
        var selected_marker = new google.maps.Marker({
            position: position,
            map: campaign_map,
            icon: 'path/to/image'
        });
    
    google.maps.event.trigger(campaign_map,'resize');
    

    EDIT You can use the following:

    https://maps.googleapis.com/maps/api/staticmap?size=480x480&markers=icon:path/to/image.png%257C996600%7Carea/you/want/
    

提交回复
热议问题