Skip to content

Instantly share code, notes, and snippets.

@kartick14
Created July 18, 2018 14:10
Show Gist options
  • Save kartick14/0e62eadd7e3f7eb8cd15a44ab1cf3a0d to your computer and use it in GitHub Desktop.
Save kartick14/0e62eadd7e3f7eb8cd15a44ab1cf3a0d to your computer and use it in GitHub Desktop.
This example displays a marker with custom color map
https://console.developers.google.com/apis/credentials?project=luca-project-210509
**Add height on map id is must
<!DOCTYPE html>
<html>
<head>
<title>Styled Maps - Night Mode</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
// This example displays a marker at the center of Australia.
// When the user clicks the marker, an info window opens.
function initMap() {
var uluru = {lat: 52.50584627069998, lng: 13.399013200000013};
var map = new google.maps.Map(document.getElementById('map'), {
center: uluru,
zoom: 14,
styles: [
{
"elementType": "geometry",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"featureType": "landscape",
"elementType": "geometry",
"stylers": [
{
"color": "#F0F5F7"
},
{
"visibility": "simplified"
}
]
},
{
"featureType": "road",
"elementType": "geometry",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{
"color": "#EE377E"
},
{
"visibility": "simplified"
},
{
"weight": 1
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.fill",
"stylers": [
{
"lightness": -5
},
{
"visibility": "simplified"
}
]
},
{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{
"color": "#93AABA"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
}
]
});
var contentString = '<div id="content">'+'<span>PROJECT XXX</span>'+'</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var marker = new google.maps.Marker({
position: uluru,
map: map,
title: 'Uluru (Ayers Rock)'
});
// marker.addListener('click', function() {
infowindow.open(map, marker);
// });
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAovhReVTu0xiVXU_pi3mUvx4tLSjDWtqQ&callback=initMap"
async defer></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment