auto / index.html
jonibtb54's picture
use google search address API - Follow Up Deployment
b641854 verified
Raw History Blame Contribute Delete
35.9 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AutoShield | Vehicle Insurance Quotes</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.globe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<style>
.hero-gradient {
background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.quote-card {
backdrop-filter: blur(10px);
background: rgba(255, 255, 255, 0.85);
}
.globe-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
opacity: 0.3;
}
</style>
</head>
<body class="font-sans antialiased">
<div id="globe-bg" class="globe-bg"></div>
<!-- Navigation -->
<nav class="relative z-10 bg-white shadow-lg">
<div class="container mx-auto px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
<i data-feather="shield" class="text-blue-600 w-8 h-8"></i>
<span class="text-xl font-bold text-blue-800">AutoShield</span>
</div>
<div class="hidden md:flex items-center space-x-8">
<a href="#" class="text-blue-800 font-medium hover:text-blue-600">Home</a>
<a href="#" class="text-gray-600 hover:text-blue-600">Coverage</a>
<a href="#" class="text-gray-600 hover:text-blue-600">Claims</a>
<a href="#" class="text-gray-600 hover:text-blue-600">About</a>
<a href="#" class="text-gray-600 hover:text-blue-600">Contact</a>
</div>
<div class="md:hidden">
<button id="menu-btn" class="text-gray-600 focus:outline-none">
<i data-feather="menu" class="w-6 h-6"></i>
</button>
</div>
</div>
</div>
</nav>
<!-- Hero Section -->
<section class="hero-gradient relative overflow-hidden text-white py-20 md:py-32">
<div class="container mx-auto px-6 text-center relative z-10">
<h1 class="text-4xl md:text-6xl font-bold mb-6" data-aos="fade-down">
Get Your Instant <span class="text-blue-200">Vehicle Insurance</span> Quote
</h1>
<p class="text-xl md:text-2xl mb-10 max-w-3xl mx-auto" data-aos="fade-down" data-aos-delay="100">
Protect your vehicle with our affordable and comprehensive coverage options
</p>
<div class="flex flex-col md:flex-row justify-center gap-4" data-aos="fade-up" data-aos-delay="200">
<a href="#quote-form" class="bg-white text-blue-800 font-bold py-3 px-8 rounded-full hover:bg-blue-100 transition duration-300 shadow-lg">
Get Quote Now
</a>
<a href="#" class="bg-transparent border-2 border-white text-white font-bold py-3 px-8 rounded-full hover:bg-white hover:text-blue-800 transition duration-300">
Learn More
</a>
</div>
</div>
</section>
<!-- Features Section -->
<section class="py-16 bg-gray-50">
<div class="container mx-auto px-6">
<h2 class="text-3xl font-bold text-center text-gray-800 mb-16">Why Choose AutoShield?</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-10">
<!-- Feature 1 -->
<div class="bg-white p-8 rounded-xl shadow-md hover:shadow-xl transition duration-300" data-aos="fade-up">
<div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mb-6">
<i data-feather="clock" class="text-blue-600 w-8 h-8"></i>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-3">Instant Quotes</h3>
<p class="text-gray-600">Get your personalized insurance quote in just a few minutes with our easy-to-use platform.</p>
</div>
<!-- Feature 2 -->
<div class="bg-white p-8 rounded-xl shadow-md hover:shadow-xl transition duration-300" data-aos="fade-up" data-aos-delay="100">
<div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mb-6">
<i data-feather="dollar-sign" class="text-blue-600 w-8 h-8"></i>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-3">Affordable Rates</h3>
<p class="text-gray-600">We work with multiple providers to ensure you get the best rates for your coverage needs.</p>
</div>
<!-- Feature 3 -->
<div class="bg-white p-8 rounded-xl shadow-md hover:shadow-xl transition duration-300" data-aos="fade-up" data-aos-delay="200">
<div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mb-6">
<i data-feather="headphones" class="text-blue-600 w-8 h-8"></i>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-3">24/7 Support</h3>
<p class="text-gray-600">Our dedicated support team is available round the clock to assist you with any queries.</p>
</div>
</div>
</div>
</section>
<!-- Quote Form Section -->
<section id="quote-form" class="py-16 bg-white">
<div class="container mx-auto px-6">
<div class="max-w-4xl mx-auto">
<div class="quote-card p-8 md:p-12 rounded-xl shadow-lg" data-aos="fade-up">
<h2 class="text-3xl font-bold text-gray-800 mb-2">Get Your Free Quote</h2>
<p class="text-gray-600 mb-8">Fill out this simple form to get your instant quote</p>
<form class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Personal Information -->
<div class="md:col-span-2">
<h3 class="text-xl font-semibold text-gray-800 mb-4 border-b pb-2">Personal Information</h3>
</div>
<div>
<label for="first-name" class="block text-gray-700 mb-2">First Name</label>
<input type="text" id="first-name" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="last-name" class="block text-gray-700 mb-2">Last Name</label>
<input type="text" id="last-name" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="email" class="block text-gray-700 mb-2">Email</label>
<input type="email" id="email" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="phone" class="block text-gray-700 mb-2">Phone</label>
<input type="tel" id="phone" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<!-- Address Information -->
<div class="md:col-span-2 mt-4">
<h3 class="text-xl font-semibold text-gray-800 mb-4 border-b pb-2">Address Information</h3>
</div>
<div class="md:col-span-2">
<label for="address-search" class="block text-gray-700 mb-2">Search NZ Address</label>
<div class="relative">
<input type="text" id="address-search" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Start typing your address...">
<button type="button" id="address-search-btn" class="absolute right-2 top-2 text-gray-500 hover:text-blue-600">
<i data-feather="search" class="w-5 h-5"></i>
</button>
</div>
<div id="address-results" class="hidden mt-2 border border-gray-200 rounded-md max-h-40 overflow-y-auto"></div>
</div>
<div class="hidden">
<input type="text" id="street-number">
<input type="text" id="street-name">
<input type="text" id="suburb">
<input type="text" id="city">
<input type="text" id="postcode">
</div>
<div class="md:col-span-2">
<label for="address" class="block text-gray-700 mb-2">Full Address</label>
<textarea id="address" rows="3" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly></textarea>
</div>
<div>
<label for="street-number" class="block text-gray-700 mb-2">Street Number</label>
<input type="text" id="street-number-display" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<div>
<label for="street-name" class="block text-gray-700 mb-2">Street Name</label>
<input type="text" id="street-name-display" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<div>
<label for="suburb" class="block text-gray-700 mb-2">Suburb</label>
<input type="text" id="suburb-display" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<div>
<label for="city" class="block text-gray-700 mb-2">City</label>
<input type="text" id="city-display" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<div>
<label for="postcode" class="block text-gray-700 mb-2">Postcode</label>
<input type="text" id="postcode-display" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<!-- Vehicle Information -->
<div class="md:col-span-2 mt-4">
<h3 class="text-xl font-semibold text-gray-800 mb-4 border-b pb-2">Vehicle Information</h3>
</div>
<div class="md:col-span-2">
<label for="rego" class="block text-gray-700 mb-2">Vehicle Registration (REGO)</label>
<div class="relative">
<input type="text" id="rego" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" placeholder="Enter NZ vehicle registration">
<button type="button" id="rego-search-btn" class="absolute right-2 top-2 text-gray-500 hover:text-blue-600">
<i data-feather="search" class="w-5 h-5"></i>
</button>
</div>
</div>
<div>
<label for="make" class="block text-gray-700 mb-2">Make</label>
<input type="text" id="make" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<div>
<label for="model" class="block text-gray-700 mb-2">Model</label>
<input type="text" id="model" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label for="year" class="block text-gray-700 mb-2">Year</label>
<input type="text" id="year" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" readonly>
</div>
<div>
<label for="mileage" class="block text-gray-700 mb-2">Mileage</label>
<input type="number" id="mileage" class="w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<!-- Coverage Options -->
<div class="md:col-span-2 mt-4">
<h3 class="text-xl font-semibold text-gray-800 mb-4 border-b pb-2">Coverage Options</h3>
</div>
<div class="md:col-span-2">
<div class="space-y-3">
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-blue-600" checked>
<span class="ml-2 text-gray-700">Liability Coverage</span>
</label>
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-blue-600">
<span class="ml-2 text-gray-700">Collision Coverage</span>
</label>
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-blue-600">
<span class="ml-2 text-gray-700">Comprehensive Coverage</span>
</label>
<label class="inline-flex items-center">
<input type="checkbox" class="form-checkbox text-blue-600">
<span class="ml-2 text-gray-700">Personal Injury Protection</span>
</label>
</div>
</div>
<!-- Submit Button -->
<div class="md:col-span-2 mt-6">
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded-md transition duration-300 shadow-md">
Get My Quote
</button>
</div>
</form>
</div>
</div>
</div>
</section>
<!-- Testimonials -->
<section class="py-16 bg-gray-50">
<div class="container mx-auto px-6">
<h2 class="text-3xl font-bold text-center text-gray-800 mb-16">What Our Customers Say</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-8">
<!-- Testimonial 1 -->
<div class="bg-white p-6 rounded-lg shadow-md" data-aos="fade-up">
<div class="flex items-center mb-4">
<div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center">
<i data-feather="user" class="text-blue-600"></i>
</div>
<div class="ml-4">
<h4 class="font-bold text-gray-800">Sarah Johnson</h4>
<div class="flex text-yellow-400">
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
</div>
</div>
</div>
<p class="text-gray-600">"AutoShield saved me over $300 a year compared to my old insurance provider. The signup process was quick and easy!"</p>
</div>
<!-- Testimonial 2 -->
<div class="bg-white p-6 rounded-lg shadow-md" data-aos="fade-up" data-aos-delay="100">
<div class="flex items-center mb-4">
<div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center">
<i data-feather="user" class="text-blue-600"></i>
</div>
<div class="ml-4">
<h4 class="font-bold text-gray-800">Michael Chen</h4>
<div class="flex text-yellow-400">
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
</div>
</div>
</div>
<p class="text-gray-600">"Their customer service is exceptional. When I had an accident, they handled everything quickly and professionally."</p>
</div>
<!-- Testimonial 3 -->
<div class="bg-white p-6 rounded-lg shadow-md" data-aos="fade-up" data-aos-delay="200">
<div class="flex items-center mb-4">
<div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center">
<i data-feather="user" class="text-blue-600"></i>
</div>
<div class="ml-4">
<h4 class="font-bold text-gray-800">David Wilson</h4>
<div class="flex text-yellow-400">
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
<i data-feather="star" class="w-4 h-4 fill-current"></i>
</div>
</div>
</div>
<p class="text-gray-600">"The online quote system was so convenient. I had multiple options to choose from within minutes."</p>
</div>
</div>
</div>
</section>
<!-- FAQ Section -->
<section class="py-16 bg-white">
<div class="container mx-auto px-6">
<h2 class="text-3xl font-bold text-center text-gray-800 mb-16">Frequently Asked Questions</h2>
<div class="max-w-3xl mx-auto space-y-6">
<!-- FAQ Item 1 -->
<div class="border border-gray-200 rounded-lg overflow-hidden" data-aos="fade-up">
<button class="faq-btn w-full flex justify-between items-center p-4 bg-gray-50 hover:bg-gray-100 transition duration-300">
<h3 class="text-lg font-semibold text-gray-800 text-left">How quickly can I get insured?</h3>
<i data-feather="chevron-down" class="text-blue-600 w-5 h-5 transform transition-transform duration-300"></i>
</button>
<div class="faq-content hidden px-4 pb-4">
<p class="text-gray-600">Once you complete your online quote and payment, your coverage begins immediately. You'll receive your insurance documents via email within minutes.</p>
</div>
</div>
<!-- FAQ Item 2 -->
<div class="border border-gray-200 rounded-lg overflow-hidden" data-aos="fade-up" data-aos-delay="100">
<button class="faq-btn w-full flex justify-between items-center p-4 bg-gray-50 hover:bg-gray-100 transition duration-300">
<h3 class="text-lg font-semibold text-gray-800 text-left">What payment options do you accept?</h3>
<i data-feather="chevron-down" class="text-blue-600 w-5 h-5 transform transition-transform duration-300"></i>
</button>
<div class="faq-content hidden px-4 pb-4">
<p class="text-gray-600">We accept all major credit cards (Visa, Mastercard, American Express, Discover), debit cards, and electronic bank transfers (ACH). You can also set up automatic payments.</p>
</div>
</div>
<!-- FAQ Item 3 -->
<div class="border border-gray-200 rounded-lg overflow-hidden" data-aos="fade-up" data-aos-delay="200">
<button class="faq-btn w-full flex justify-between items-center p-4 bg-gray-50 hover:bg-gray-100 transition duration-300">
<h3 class="text-lg font-semibold text-gray-800 text-left">Can I customize my coverage?</h3>
<i data-feather="chevron-down" class="text-blue-600 w-5 h-5 transform transition-transform duration-300"></i>
</button>
<div class="faq-content hidden px-4 pb-4">
<p class="text-gray-600">Absolutely! Our quote system allows you to select exactly the coverage options you need. You can adjust your deductibles, coverage limits, and add-ons to create a policy that fits your budget and protection needs.</p>
</div>
</div>
<!-- FAQ Item 4 -->
<div class="border border-gray-200 rounded-lg overflow-hidden" data-aos="fade-up" data-aos-delay="300">
<button class="faq-btn w-full flex justify-between items-center p-4 bg-gray-50 hover:bg-gray-100 transition duration-300">
<h3 class="text-lg font-semibold text-gray-800 text-left">What if I need to file a claim?</h3>
<i data-feather="chevron-down" class="text-blue-600 w-5 h-5 transform transition-transform duration-300"></i>
</button>
<div class="faq-content hidden px-4 pb-4">
<p class="text-gray-600">You can file a claim 24/7 through our mobile app, online portal, or by calling our claims hotline. We have a network of trusted repair shops and will guide you through every step of the process.</p>
</div>
</div>
</div>
</div>
</section>
<!-- Call to Action -->
<section class="py-16 bg-blue-800 text-white">
<div class="container mx-auto px-6 text-center">
<h2 class="text-3xl md:text-4xl font-bold mb-6">Ready to Save on Your Auto Insurance?</h2>
<p class="text-xl mb-10 max-w-2xl mx-auto">Join thousands of satisfied customers who trust AutoShield for their vehicle insurance needs.</p>
<a href="#quote-form" class="inline-block bg-white text-blue-800 font-bold py-3 px-8 rounded-full hover:bg-blue-100 transition duration-300 shadow-lg">
Get Your Free Quote
</a>
</div>
</section>
<!-- Footer -->
<footer class="bg-gray-900 text-white py-12">
<div class="container mx-auto px-6">
<div class="grid grid-cols-1 md:grid-cols-4 gap-10">
<!-- Company Info -->
<div>
<div class="flex items-center space-x-2 mb-4">
<i data-feather="shield" class="text-blue-400 w-8 h-8"></i>
<span class="text-xl font-bold">AutoShield</span>
</div>
<p class="text-gray-400 mb-4">Protecting what matters most with affordable and reliable vehicle insurance solutions.</p>
<div class="flex space-x-4">
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i data-feather="facebook" class="w-5 h-5"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i data-feather="twitter" class="w-5 h-5"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i data-feather="instagram" class="w-5 h-5"></i>
</a>
<a href="#" class="text-gray-400 hover:text-white transition duration-300">
<i data-feather="linkedin" class="w-5 h-5"></i>
</a>
</div>
</div>
<!-- Quick Links -->
<div>
<h3 class="text-lg font-semibold mb-4">Quick Links</h3>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Home</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Get a Quote</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Coverage Options</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Claims</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Contact Us</a></li>
</ul>
</div>
<!-- Coverage Types -->
<div>
<h3 class="text-lg font-semibold mb-4">Coverage Types</h3>
<ul class="space-y-2">
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Liability</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Collision</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Comprehensive</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Personal Injury</a></li>
<li><a href="#" class="text-gray-400 hover:text-white transition duration-300">Roadside Assistance</a></li>
</ul>
</div>
<!-- Contact Info -->
<div>
<h3 class="text-lg font-semibold mb-4">Contact Us</h3>
<ul class="space-y-3">
<li class="flex items-start">
<i data-feather="map-pin" class="text-blue-400 w-5 h-5 mt-1 mr-2"></i>
<span class="text-gray-400">123 Insurance Way, Suite 100<br>San Francisco, CA 94107</span>
</li>
<li class="flex items-center">
<i data-feather="phone" class="text-blue-400 w-5 h-5 mr-2"></i>
<span class="text-gray-400">(800) 555-1234</span>
</li>
<li class="flex items-center">
<i data-feather="mail" class="text-blue-400 w-5 h-5 mr-2"></i>
<span class="text-gray-400">info@autoshield.com</span>
</li>
</ul>
</div>
</div>
<div class="border-t border-gray-800 mt-10 pt-8 text-center text-gray-500 text-sm">
<p>© 2023 AutoShield Insurance. All rights reserved.</p>
</div>
</div>
</footer>
<script>
// Initialize AOS animation
AOS.init({
duration: 800,
easing: 'ease-in-out',
once: true
});
// Initialize Vanta.js globe background
VANTA.GLOBE({
el: "#globe-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x3b82f6,
backgroundColor: 0xffffff,
size: 1.00
});
// Initialize feather icons
feather.replace();
// Google Places API for NZ Address Lookup
const addressSearch = document.getElementById('address-search');
const addressResults = document.getElementById('address-results');
// Initialize Google Places Autocomplete
let autocomplete;
function initGooglePlaces() {
// Create autocomplete instance
autocomplete = new google.maps.places.Autocomplete(addressSearch, {
types: ['address'],
componentRestrictions: { country: 'nz' }
});
// When a place is selected
autocomplete.addListener('place_changed', function() {
const place = autocomplete.getPlace();
if (!place.geometry) {
console.log("No details available for input: '" + place.name + "'");
return;
}
// Parse address components
let streetNumber = '';
let streetName = '';
let suburb = '';
let city = '';
let postcode = '';
let fullAddress = place.formatted_address;
// Parse address components
place.address_components.forEach(component => {
const types = component.types;
if (types.includes('street_number')) {
streetNumber = component.long_name;
} else if (types.includes('route')) {
streetName = component.long_name;
} else if (types.includes('sublocality_level_1') || types.includes('locality')) {
suburb = component.long_name;
} else if (types.includes('administrative_area_level_1')) {
city = component.long_name;
} else if (types.includes('postal_code')) {
postcode = component.long_name;
}
});
// Update all fields
document.getElementById('address').value = fullAddress;
document.getElementById('street-number').value = streetNumber;
document.getElementById('street-name').value = streetName;
document.getElementById('suburb').value = suburb;
document.getElementById('city').value = city;
document.getElementById('postcode').value = postcode;
// Update displayed fields
document.getElementById('street-number-display').value = streetNumber;
document.getElementById('street-name-display').value = streetName;
document.getElementById('suburb-display').value = suburb;
document.getElementById('city-display').value = city;
document.getElementById('postcode-display').value = postcode;
addressResults.classList.add('hidden');
});
}
// Load Google Maps API with Places library
function loadGoogleMapsAPI() {
const script = document.createElement('script');
script.src = 'https://maps.googleapis.com/maps/api/js?key=YOUR_GOOGLE_MAPS_API_KEY&libraries=places&callback=initGooglePlaces';
script.async = true;
script.defer = true;
document.head.appendChild(script);
}
// Start loading Google Maps API
loadGoogleMapsAPI();
// Manual search button functionality
document.getElementById('address-search-btn').addEventListener('click', function() {
addressSearch.focus();
});
// Close address results when clicking outside
document.addEventListener('click', function(e) {
if (!e.target.closest('#address-search') && !e.target.closest('#address-results')) {
addressResults.classList.add('hidden');
}
});
// Also trigger search on button click
document.getElementById('address-search-btn').addEventListener('click', function() {
const event = new Event('input', {
bubbles: true,
cancelable: true,
});
addressSearch.dispatchEvent(event);
});
// FAQ toggle functionality
document.querySelectorAll('.faq-btn').forEach(button => {
button.addEventListener('click', () => {
const content = button.nextElementSibling;
const icon = button.querySelector('i');
// Toggle content
content.classList.toggle('hidden');
// Rotate icon
if (content.classList.contains('hidden')) {
icon.style.transform = 'rotate(0deg)';
} else {
icon.style.transform = 'rotate(180deg)';
}
});
});
</script>
</body>
</html>