-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfont_awesome_marker.html
92 lines (83 loc) · 3.26 KB
/
font_awesome_marker.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
#map {
position: absolute;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.min.css">
</head>
<body>
<a href="https://onethinglab.wordpress.com/the-definitive-guide-to-google-maps-markers#marker-font-awesome">How to use Font Awesome as marker icon</a>
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="lib/js-rich-marker/src/richmarker.js"></script>
<script>
// initialize google maps instance and put markers on map
init_map();
function add_marker(gmap, coordinates, content) {
var marker = new RichMarker({
position: new google.maps.LatLng(coordinates),
map: gmap,
flat: true,
anchor: RichMarkerPosition.MIDDLE,
content: content
});
return marker;
}
function init_map() {
var places = {
'JP': [{
'coordinates': { lat: 65.762217, lng: -150.292969 },
'content': '<i class="fa fa-tree fa-2x" style="color:green"></i>'
},
{
'coordinates': { lat: 65.762217, lng: -131.308594 },
'content': '<i class="fa fa-space-shuttle fa-2x""></i>'
},
{
'coordinates': { lat: 62.709425, lng: -112.675781 },
'content': '<i class="fa fa-taxi fa-2x"></i>'
}],
'US': [{
'coordinates': { lat: 57.273104, lng: -110.917969 },
'content': '<i class="fa fa-university fa-2x" style="color:grey"></i>'
},
{
'coordinates': { lat: 44.016521, lng: -87.011719 },
'content': '<i class="fa fa-truck fa-2x"></i>'
},
{
'coordinates': { lat: 27.283926, lng: 2.636719 },
'content': '<i class="fa fa-wifi fa-2x" style="color:red"></i>'
}],
'MG': [{
'coordinates': { lat: 27.283926, lng: 8.261719 },
'content': '<i class="fa fa-spinner fa-spin fa-2x fa-fw" style="color:red"></i>'
},
{
'coordinates': { lat: 16.541430, lng: 27.597656 },
'content': '<i class="fa fa-circle-o-notch fa-spin fa-fw fa-2x" style="color:blue"></i>'
},
{
'coordinates': { lat: 48.857487, lng: 33.222656 },
'content': '<i class="fa fa-gear fa-spin fa-fw fa-2x" style="color:green"></i>'
}]
};
var gmap = new google.maps.Map(document.getElementById('map'),
{
zoom: 3,
center: { lat: 27.283926, lng: 2.636719 }
});
for (var country in places) {
places[country].forEach(place => add_marker(gmap, place['coordinates'],
place['content']));
}
}
</script>
</body>
</html>