Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (83 sloc) 3.26 KB
<!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>