Google Map Customized InfoWindow Hack

Size
3,727 Kb
Views
32,384

How do I make an google map customized infowindow hack?

What is a google map customized infowindow hack? How do you make a google map customized infowindow hack? This script and codes were developed by Ahsan K. Rathore on 27 November 2022, Sunday.

Google Map Customized InfoWindow Hack Previews

Google Map Customized InfoWindow Hack - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Google Map Customized InfoWindow Hack</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id="map"></div> <script src='https://maps.googleapis.com/maps/api/js?v=3.20&sensor=false'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.2/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Google Map Customized InfoWindow Hack - Script Codes CSS Codes

#map {	margin: 0;	padding: 0;	height: 815px;	max-width: none;
}
#map img {	max-width: none !important;
}
#marker-tooltip { display: none; position:absolute; width: 300px; height: 200px; background-color: #ccc; margin: 15px;
}
.gm-style-iw {	width: 350px !important;	top: 15px !important;	left: 0px !important;	background-color: #fff;	box-shadow: 0 1px 6px rgba(178, 178, 178, 0.6);	border: 1px solid rgba(72, 181, 233, 0.6);	border-radius: 2px 2px 10px 10px;
}
#iw-container {	margin-bottom: 10px; width: 350px !important;
}
#iw-container .iw-title {	font-family: 'Open Sans', sans-serif;	font-size: 18px;	font-weight: 400;	padding: 5px 10px;	background-color: #48b5e9;	color: white;	margin: 0;	border-radius: 2px 2px 0 0; width: 100%; box-sizing: border-box;
}
.iw-titleSub { display: block; margin-top: 0px; font-size: 15px;	font-weight: 300; color: #f4f4f4;
}
#iw-container .iw-content {	font-size: 13px;	line-height: 18px;	font-weight: 400;	margin-right: 1px;	padding: 15px 5px 20px 15px;	max-height: 160px;	overflow-y: auto;	overflow-x: hidden;
}
.iw-content img {	float: right;	margin: 0 5px 5px 10px;
}
.iw-row { overflow: auto; /*border-bottom: 1px solid #ccc; */
}
.iw-subTitle {	font-size: 14px;	font-weight: 700;	padding: 5px 0; float: left;
}
.iw-subTitleDesc { font-size: 14px;	font-weight: 400; float: right; padding: 5px 5px 5px 0;
}
.iw-bottom-gradient {	position: absolute;	width: 326px;	height: 25px;	bottom: 10px;	right: 18px;	background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);	background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);	background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);	background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%);
}

Google Map Customized InfoWindow Hack - Script Codes JS Codes

(function () { var pos = new google.maps.LatLng(43.714604, -79.334078); var map = new google.maps.Map($('#map')[0], { center: pos, zoom: 12, mapTypeId: google.maps.MapTypeId.ROAD }); var marker = new google.maps.Marker({ position: pos, map: map }); var content = '<div id="iw-container">' + '<div class="iw-title">MICHAEL HEAD</div>' + '<div class="iw-content">' + '<div class="iw-row"><div class="iw-subTitle">Patient Count</div>' + '<span class="iw-subTitleDesc">56</span></div>' + '<div class="iw-row"><div class="iw-subTitle">Total Cost:</div>' + '<span class="iw-subTitleDesc">$ 934,342</span></div>'+ '<div class="iw-row"><div class="iw-subTitle">Taxonomy Code</div>' + '<span class="iw-subTitleDesc">152W00000X</span></div>'+ '<div class="iw-row"><div class="iw-subTitle">Taxonomy Detail</div>' + '<span class="iw-subTitleDesc">Eye and Vision Service Providers/Optometrist Allopathic & Osteopathic Physicians/Radiology, Diagnostic Radiology Physician Assistants & Advanced Practice Nursing Providers/Physician Assistant</span></div>'+ '</div>' + '<div class="iw-bottom-gradient"></div>' + '</div>'; var infoWindow = new google.maps.InfoWindow({ content: content, maxWidth: 350 }); google.maps.event.addListener(marker, 'click', function () { infoWindow.open(map, marker); }); google.maps.event.addListener(marker, 'mouseout', function () { $('#marker-tooltip').hide(); }); google.maps.event.addListener(infoWindow, 'domready', function() { // Reference to the DIV that wraps the bottom of infowindow var iwOuter = $('.gm-style-iw'); /* Since this div is in a position prior to .gm-div style-iw. * We use jQuery and create a iwBackground variable, * and took advantage of the existing reference .gm-style-iw for the previous div with .prev(). */ var iwBackground = iwOuter.prev(); // Removes background shadow DIV iwBackground.children(':nth-child(2)').css({'display' : 'none'}); // Removes white background DIV iwBackground.children(':nth-child(4)').css({'display' : 'none'}); // Moves the infowindow 115px to the right. iwOuter.parent().parent().css({left: '115px'}); // Moves the shadow of the arrow 76px to the left margin. iwBackground.children(':nth-child(1)').attr('style', function(i,s){ return s + 'left: 76px !important;'}); // Moves the arrow 76px to the left margin. iwBackground.children(':nth-child(3)').attr('style', function(i,s){ return s + 'left: 76px !important;'}); // Changes the desired tail shadow color. iwBackground.children(':nth-child(3)').find('div').children().css({'box-shadow': 'rgba(72, 181, 233, 0.6) 0px 1px 6px', 'z-index' : '1'}); // Reference to the div that groups the close button elements. var iwCloseBtn = iwOuter.next(); // Apply the desired effect to the close button iwCloseBtn.css({opacity: '1', right: '58px', top: '20px', border: '7px solid #48b5e9', 'border-radius': '13px'}); // If the content of infowindow not exceed the set maximum height, then the gradient is removed. if($('.iw-content').height() < 140){ $('.iw-bottom-gradient').css({display: 'none'}); } // The API automatically applies 0.7 opacity to the button after the mouseout event. This function reverses this event to the desired value. iwCloseBtn.mouseout(function(){ $(this).css({opacity: '1'}); }); }); //google.maps.event.addDomListener(window, 'load', initialize);
})();
function fromLatLngToPoint(latLng, map) { var topRight = map.getProjection().fromLatLngToPoint(map.getBounds().getNorthEast()); var bottomLeft = map.getProjection().fromLatLngToPoint(map.getBounds().getSouthWest()); var scale = Math.pow(2, map.getZoom()); var worldPoint = map.getProjection().fromLatLngToPoint(latLng); return new google.maps.Point((worldPoint.x - bottomLeft.x) * scale, (worldPoint.y - topRight.y) * scale);
}
Google Map Customized InfoWindow Hack - Script Codes
Google Map Customized InfoWindow Hack - Script Codes
Home Page Home
Developer Ahsan K. Rathore
Username ahsanrathore
Uploaded November 27, 2022
Rating 3
Size 3,727 Kb
Views 32,384
Do you need developer help for Google Map Customized InfoWindow Hack?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Ahsan K. Rathore (ahsanrathore) Script Codes
Create amazing SEO content with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!