What are you looking for?
What are you looking for?
Google Maps is one of the most powerful tools for displaying interactive maps on your website. Whether you're building a store locator, contact page, or delivery tracking, integrating Google Maps can enhance both user experience and trust. This guide shows you how to easily embed and customize Google Maps on your website using the official API.
Integrating Google Maps provides:
Go to the Google Cloud Console, create a project, and enable the “Maps JavaScript API.” Then go to **Credentials** and generate an API key.
Place this script at the bottom of your HTML file before `
`. Replace `YOUR_API_KEY` with your real key.
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script>
Add a `div` where the map will be displayed:
<div id="map" style="height: 400px; width: 100%;"></div>
<script> function initMap() { const location = { lat: 33.6844, lng: 73.0479 }; // Example: Islamabad const map = new google.maps.Map(document.getElementById("map"), { zoom: 12, center: location, }); const marker = new google.maps.Marker({ position: location, map: map, }); } </script>
Google Maps integration is a simple but powerful enhancement for websites. With a free API key and a few lines of code, you can display interactive, zoomable, and customizable maps that improve usability and professionalism.