将图标添加到谷歌地图

时间:2015-12-09 03:06:36

标签: javascript angularjs google-maps ng-map

我有这个用于显示中心地图为[40.74,-74.18]的谷歌地图。

http://plnkr.co/edit/BfYggKO8nDolhmpq92dq?p=preview

#include <stdio.h>

int main(void){
    char input;

    if(scanf("%c", &input) == 1){
        if(input != '1' && input != 'Q' || getchar() != '\n'){
            fprintf(stderr, "input error!\n");
            while(getchar() != '\n');//clear input
        } else {
            printf("your input is %c\n", input);
        }
    }
    return 0;
}

代码使用angularjs。使用的google-map angularjs库是http://ngmap.github.io/

我想在附近点添加下面的图标,比如说[50.74,-74.18]。怎么办呢?

enter image description here

1 个答案:

答案 0 :(得分:2)

您可以为icon指令指定marker属性以设置自定义标记图标:

<script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script>
<script src="https://code.angularjs.org/1.3.15/angular.js"></script>
<script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script>
<div ng-app="ngMap">
   <ng-map center="[54.74, -74.18]" style="height: 480px;" zoom="4" >
      <marker position="50.74, -74.18" title="Hello World!" icon="http://s19.postimg.org/scc4cevlv/marker_Icon.png"></marker>
   </ng-map>
</div>  

Plunker