Using a custom image marker on google static map?

前端 未结 3 1664
轮回少年
轮回少年 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:14

    This is what you want:

    http://maps.googleapis.com/maps/api/staticmap?zoom=17&size=512x512&maptype=hybrid&markers=icon:http://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico|34.052230,-118.243680

    for a custom image, put the icon:url after of markers...

    Format

    icon:url|lat,lng
    

    Example

    icon:http://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico|34.052230,-118.243680
    

    a result of my example

    For more information check google maps api, there are more information like size, markers position, center map, map type... etc.

    https://developers.google.com/maps/documentation/static-maps/intro#MapTypes

    *If the icon, img, don't appear it will be the size of image, try with another size,less than 64x64 px, format of image, "GIF, JPEG and PNG", the documentation recommend "PNG", if it doesn't appear check permision of image for public request(external request)...

提交回复
热议问题