Directions to Our Sultanganj, Patna Location
body { font-family: Arial, sans-serif; margin: 0; padding: 16px; box-sizing: border-box; }
.container { max-width: 900px; margin: 0 auto; }
h1 { margin: 0 0 8px; font-size: 20px; }
.biz-info { background:#f6f7fb; padding:12px; border-radius:8px; margin-bottom:12px; }
#map { width:100%; height:420px; border-radius:8px; margin-bottom:8px; }
.controls { display:flex; gap:8px; align-items:center; margin-bottom:12px; }
input#addressInput { flex:1; padding:10px 12px; font-size:16px; border-radius:6px; border:1px solid #d0d0d0; }
button { padding:10px 12px; border-radius:6px; border: none; background:#2b78f6; color:white; cursor:pointer; font-size:14px; }
button:disabled { opacity:.5; cursor:not-allowed; }
.steps { max-height:240px; overflow:auto; border:1px solid #eee; padding:10px; border-radius:8px; background:#fff; }
.step { margin-bottom:8px; font-size:14px; }
.small { font-size:13px; color:#666; margin-top:6px; }
@media (max-width:600px) {
#map { height:320px; }
}
Lucas Productions — Sultanganj (Patna)
Sultanganj, Patna, Bihar, India — 25.240129, 86.740440
Enter your start address below to see the route to our location.
Directions (step by step)
// ==== CONFIG ====
// Business coordinates (replace if you want a different point)
const BIZ = { lat: 25.240129, lng: 86.740440 };
let map, marker, autocomplete, directionsService, directionsRenderer;
function initMap() {
// Create map centered on business
map = new google.maps.Map(document.getElementById('map'), {
center: BIZ,
zoom: 14,
mapTypeControl: false,
fullscreenControl: false,
});
// Business marker
marker = new google.maps.Marker({
position: BIZ,
map: map,
title: "Lucas Productions - Sultanganj (Patna)",
});
// Directions
directionsService = new google.maps.DirectionsService();
directionsRenderer = new google.maps.DirectionsRenderer({
map: map,
suppressMarkers: false, // keep markers for origin & dest
draggable: false,
});
// Autocomplete for the input field (Places)
const input = document.getElementById('addressInput');
autocomplete = new google.maps.places.Autocomplete(input, {
types: ['geocode', 'establishment'],
// componentRestrictions: { country: 'in' } // uncomment to restrict to India
});
autocomplete.setFields(['formatted_address', 'geometry', 'name', 'place_id']);
// When user selects suggestion from dropdown
autocomplete.addListener('place_changed', () => {
const place = autocomplete.getPlace();
if (!place.geometry) {
showMessage('No details available for that input. Try typing an address and selecting a suggestion.');
return;
}
const originLatLng = place.geometry.location;
requestRoute({ lat: originLatLng.lat(), lng: originLatLng.lng() }, place.formatted_address || place.name);
});
// Button handlers
document.getElementById('routeBtn').addEventListener('click', () => {
const text = input.value.trim();
if (!text) { showMessage('Please enter a starting address.'); return; }
// If user typed but didn't select suggestion, geocode (get lat/lng) then draw
geocodeAndRoute(text);
});
document.getElementById('clearBtn').addEventListener('click', () => {
input.value = '';
directionsRenderer.setDirections({ routes: [] });
document.getElementById('steps').innerHTML = '';
map.setCenter(BIZ);
map.setZoom(14);
showMessage('');
});
// Pressing Enter in input should attempt to route
input.addEventListener('keydown', (ev) => {
if (ev.key === 'Enter') {
ev.preventDefault();
document.getElementById('routeBtn').click();
}
});
}
// Geocode a free-text address (when user types and hits Enter)
function geocodeAndRoute(addressText) {
const geocoder = new google.maps.Geocoder();
showMessage('Looking up the address...');
geocoder.geocode({ address: addressText }, (results, status) => {
if (status === 'OK' && results && results[0]) {
const loc = results[0].geometry.location;
requestRoute({ lat: loc.lat(), lng: loc.lng() }, results[0].formatted_address);
} else {
showMessage('Could not find that address. Try a different address or select a suggestion.');
}
});
}
// Request directions origin -> BIZ
function requestRoute(originLatLng, originLabel) {
showMessage('Calculating route...');
const request = {
origin: { lat: originLatLng.lat, lng: originLatLng.lng },
destination: { lat: BIZ.lat, lng: BIZ.lng },
travelMode: google.maps.TravelMode.DRIVING, // or WALKING / BICYCLING / TRANSIT
provideRouteAlternatives: false,
};
directionsService.route(request, (result, status) => {
if (status === 'OK' && result) {
directionsRenderer.setDirections(result);
// Fit map viewport to route
const bounds = new google.maps.LatLngBounds();
const route = result.routes[0];
route.overview_path.forEach(p => bounds.extend(p));
map.fitBounds(bounds);
// Show step-by-step
showSteps(route);
showMessage(`Route shown from "${originLabel || 'your location'}" to Lucas Productions.`);
} else {
showMessage('Could not compute directions. ' + status);
}
});
}
function showSteps(route) {
const stepsDiv = document.getElementById('steps');
stepsDiv.innerHTML = '';
if (!route.legs || route.legs.length === 0) return;
const leg = route.legs[0];
// Summary
const summary = document.createElement('div');
summary.className = 'step';
summary.innerHTML = `
Distance: ${leg.distance.text} •
Duration: ${leg.duration.text}`;
stepsDiv.appendChild(summary);
leg.steps.forEach((s, i) => {
const d = document.createElement('div');
d.className = 'step';
// strip HTML tags a bit (step.instructions contains HTML)
const instr = s.instructions.replace(/(]+)>)/gi, "");
d.innerHTML = `
${i+1}. ${instr}
${s.distance.text}, ${s.duration.text}
`;
stepsDiv.appendChild(d);
});
}
function showMessage(msg) {
document.getElementById('message').textContent = msg || '';
}
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places&callback=initMap">