Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=KEY HERE"></script>
- <style>
- #map {
- height: 400px;
- width: 100%;
- }
- </style>
- <div id="map"></div>
- <script>
- google.maps.event.addDomListener(window, 'load', init);
- function init() {
- var areaName = 'JUST THE NAME OF THE AREA HERE';
- getCoordinates(areaName, function(coordinates) {
- var mapOptions = {
- zoom: 18,
- center: coordinates,
- styles: [
- {
- "featureType": "administrative",
- "elementType": "labels.text.fill",
- "stylers": [
- {
- "color": "#444444"
- }
- ]
- },
- {
- "featureType": "landscape",
- "elementType": "all",
- "stylers": [
- {
- "color": "#f2f2f2"
- }
- ]
- },
- {
- "featureType": "landscape",
- "elementType": "geometry.fill",
- "stylers": [
- {
- "color": "#f0f0f0"
- }
- ]
- },
- {
- "featureType": "poi",
- "elementType": "all",
- "stylers": [
- {
- "visibility": "off"
- }
- ]
- },
- {
- "featureType": "road",
- "elementType": "all",
- "stylers": [
- {
- "saturation": -100
- },
- {
- "lightness": 45
- }
- ]
- },
- {
- "featureType": "road.highway",
- "elementType": "all",
- "stylers": [
- {
- "visibility": "simplified"
- }
- ]
- },
- {
- "featureType": "road.arterial",
- "elementType": "labels.icon",
- "stylers": [
- {
- "visibility": "off"
- }
- ]
- },
- {
- "featureType": "transit",
- "elementType": "all",
- "stylers": [
- {
- "visibility": "off"
- }
- ]
- },
- {
- "featureType": "water",
- "elementType": "all",
- "stylers": [
- {
- "color": "#9d9d9e"
- },
- {
- "visibility": "on"
- }
- ]
- }
- ],
- disableDefaultUI: true // Disable all default UI
- };
- var mapElement = document.getElementById('map');
- var map = new google.maps.Map(mapElement, mapOptions);
- // SVG marker icon
- var svgMarker = {
- path: "M19.4996 0C8.72871 0 0 8.869 0 19.8022C0 20.3677 0.0314066 20.9191 0.0743033 21.4737C0.0926876 21.6697 0.117199 21.875 0.140179 22.0663C0.17465 22.4 0.217547 22.7282 0.2727 23.0541C0.31483 23.3147 0.354663 23.5706 0.408284 23.8241C0.442755 23.9991 0.48795 24.1741 0.524718 24.3491C2.29804 32.1844 8.30281 38.4689 12.9311 49.2279C14.3145 52.4471 15.5232 55.8973 16.5122 59.0497L19.4996 70L22.4871 59.0481C23.4775 55.8966 24.6848 52.4456 26.0682 49.2263C30.6964 38.4673 36.7035 32.1829 38.4684 24.3476C38.5144 24.1726 38.5481 23.9976 38.5848 23.8226C38.6354 23.5698 38.6806 23.3139 38.7227 23.0526C38.7725 22.7267 38.8246 22.3984 38.8591 22.0648C38.8828 21.8734 38.9066 21.6689 38.9219 21.4721C38.9701 20.9176 39 20.3661 39 19.8007C38.9992 8.869 30.2705 0 19.4996 0ZM19.4966 28.7513C14.6324 28.7513 10.6851 24.7411 10.6851 19.7991C10.6851 14.8571 14.6324 10.8523 19.4966 10.8523C24.3661 10.8523 28.3134 14.8571 28.3134 19.7991C28.3134 24.7411 24.3669 28.7513 19.4966 28.7513Z",
- fillColor: "#C71781",
- fillOpacity: 1,
- strokeWeight: 0,
- scale: 0.9,
- anchor: new google.maps.Point(19.5, 70) // anchor at the base of the marker
- };
- var marker = new google.maps.Marker({
- position: coordinates,
- map: map,
- title: areaName,
- icon: svgMarker
- });
- var infoWindow = new google.maps.InfoWindow({
- content: '<div>' +
- '<img src="IMAGE HERE" style="width:100px;height:auto;float:left;margin-right:10px;">' +
- '<strong>' + areaName + '</strong><br>' +
- 'Address: ADDRESS HERE<br>' +
- '<a href="DIRECTIONS LINK HERE" target="_blank">Get Directions</a>' +
- '</div>'
- });
- marker.addListener('click', function() {
- infoWindow.open(map, marker);
- });
- });
- }
- function getCoordinates(address, callback) {
- var geocoder = new google.maps.Geocoder();
- geocoder.geocode({ 'address': address }, function(results, status) {
- if (status === 'OK') {
- var coordinates = results[0].geometry.location;
- callback(coordinates);
- } else {
- alert('Geocode was not successful for the following reason: ' + status);
- }
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement