This code styles elements for a Google Map integration using Material Design. It customizes various components’ appearance and animations, like buttons and headers. The JavaScript part adds toggle effects to certain elements, enhancing visual transitions. This code aims to offer a Material Design-themed interface for Google Maps integration.
How to Integrate Google Map Using Material Design
1. First of all, load the Modernizr JS and Reset CSS by adding the following CDN links into the head tag of your HTML document.
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js" type="text/javascript"></script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css">
2. Create your HTML structure for the Google Maps integration as follows:
<div class="header"> <h1>Materiella</h1> </div> <div class="item"> <div class="primary"> <div class="spoiler"> <div>Your</div> <div>Present</div> </div> <iframe class="present" src="https://www.google.com/maps/embed?pb=!1m10!1m8!1m3!1d178688.38038032036!2d-1.0667825132755415!3d45.59042526411341!3m2!1i1024!2i768!4f13.1!5e0!3m2!1sen!2sde!4v1411841033913" width="600" height="450" frameborder="0" style="border:0"></iframe> </div> <div class="title"> <h2>Click to open ...</h2> <div class="circle-wrap"> <button tabindex="1" type="button" class="toggle-tada"> <div class="caret-wrap"> <span class="caret"> > </span> </div> </button> </div> <div class="secondary"> <p> By clicking the colourful button, You agree the terms and conditions and Your Present will appear and make you happy! </p> </div> </div> </div>
3. Style the map card using the following CSS styles. The following CSS code styles various components like buttons, headers, and transitions, maintaining a Material Design aesthetic. Modify the CSS properties within the provided code to match your project’s color scheme or specific design requirements.
@import url(https://fonts.googleapis.com/css?family=Roboto:400,100); html * { font-family: Roboto !important; font-weight: 100; box-sizing: border-box; } .circle-wrap { width: 50px; height: 50px; position: absolute; pointer: cursor; top: -19px; right: 20px; transition: all 0.6s ease; transform: scale(1, 1); } .circle-wrap > * { outline: 0; border: none; cursor: pointer; width: 100%; border-radius: 50%; text-align: center; padding: 50% 0; line-height: 0; margin: 0; background-color: #e95de3; color: white; font-size: 20px; box-shadow: 2px 2px 10px -2px #4d4d4d; } .tada2 .circle-wrap { transition: all 0.6s ease; transform: scale(0.8, 0.8); } .header { height: 60px; width: 100%; background-color: #17a5a5; color: white; box-shadow: 2px 2px 5px 2px #ddd; } .header h1 { text-align: center; position: relative; top: 50%; transform: translateY(-50%); margin: 0 auto; font-size: 30px; } ul { width: 100%; } .item { overflow: hidden; margin: 80px auto; max-width: 600px; width: 100%; } .primary { height: 300px; background-color: #eee; color: darkgray; font-size: 50px; position: relative; text-align: right; } .primary .spoiler { margin: 0 10px; position: absolute; bottom: 40px; right: 0; } .present { position: absolute; top: 0px; left: 0px; width: 100%; height: calc(100% + 77px); background-color: red; transform: translateY(100%); transition: all 0.8s 0.05s ease; } .present.tada { transition: all 0.5s ease; transform: translateY(0%); } .title, .secondary { padding: 0 10px; z-index: 2; background-color: #fafafa; } .title { border-top: 1px solid #dadada; position: relative; width: 100%; color: #868686; font-size: 30px; padding: 10px 10px; transition: all 0.6s ease; } .secondary { color: #acacac; line-height: 20px; font-size: 14px; padding: 20px 0; } .title.tada2 { transform: translateY(77px); transition: all 0.6s ease; } .caret-wrap { transform: rotate(90deg); transition: all 0.6s ease; } .caret { display: block; transform: scaleY(2); } .tada2 .caret-wrap { transform: rotate(270deg); }
4. Load the jQuery JavaScript library by adding the following CDN link just before closing the body tag:
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
5. Finally, add the following JavaScript function to your project to toggle the map view.
setTimeout(function() { $('.present').toggleClass('tada'); $('.title').toggleClass('tada2'); },2000); $('.toggle-tada').click(function() { $('.present').toggleClass('tada'); $('.title').toggleClass('tada2'); });
Adjust and integrate it into your project to enhance the visual appeal and user experience of your map interface.
That’s all! hopefully, you have successfully integrated this Material Design Google Map card on your website. If you have any questions or suggestions, feel free to comment below.
Similar Code Snippets:
I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences.
I truly enjoy what I’m doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.