Click on map and get Longitude -Latitude.

Map

How To Get Longitude – Latitude When Clicked On Map?


<div id="MyMap" style="width:100%;height:500px;"></div>
<script>
function myMap() {
  var mapCanvas = document.getElementById("MyMap");
  var myCenter=new google.maps.LatLng(51.508742,-0.120850);
  var mapOptions = {center: myCenter, zoom: 5};
  var map = new google.maps.Map(mapCanvas, mapOptions);
  google.maps.event.addListener(map,'click', function(event) {
    LocationMarker(map, event.latLng);
  });
}
function LocationMarker(map, location) {
  var marker = new google.maps.Marker({
    position: location,
    map: map
  });
  var infowindow = new google.maps.InfoWindow({
    content: 'Latitude: ' + location.lat() + '<br>Longitude: ' + location.lng()
  });
  infowindow.open(map,marker);
}
</script>

<script src="https://maps.googleapis.com/maps/api/js?key=YourKey&callback=myMap"></script>
//Get API key from Google.
//Read more at: https://developers.google.com/maps/documentation/javascript/get-api-key
Click on map and get Longitude -Latitude. – screenshot 1

Related reading:

Shiv Kumawat

Executive Director & CEO

Shiv Kumawat is the CEO of Eoxys IT Solution LLP, the Jaipur-based IT company he has led since 2009. An AI & IT Solutions Consultant with 16+ years of experience, he works with startups and enterprises to turn ideas into market-ready SaaS platforms, mobile apps and AI-driven solutions. His team has delivered 700+ projects across SaaS, mobile and web apps, automation and AI. He previously served as Chief Technology Officer for a US company.

Latest Posts

Colour photograph illustrating the Eoxys blog post 'Small Language Models vs LLMs: Which Should Your App Use?', used as the featured image for small language models vs llms.

Small Language Models vs LLMs: Which Should Your App Use?

Not every AI feature needs the biggest model. Small language models (SLMs) are compact models that can run on a…

Shafeeq Khan
December 5, 2026
Eoxys banner for a post-quantum cryptography business guide, showing a close-up of a gold-pin computer processor on a dark blue background

Post-Quantum Cryptography in 2027: A Business Migration Guide

Post-quantum cryptography (PQC) went from a 2030 planning topic to this week’s security headline. On 2 December 2026 the NSA,…

Shafeeq Khan
December 4, 2026
Eoxys banner: Restaurant Ordering App Development Cost in the USA, 2027 guide, with a guest waiting under a Pick Up Here sign in a restaurant

Restaurant Ordering App Development Cost in the USA (2027)

A restaurant ordering app is judged at the pickup shelf. If the app promises 15 minutes and the kitchen needs…

Shafeeq Khan
December 4, 2026
,

Leave a Reply

Your email address will not be published. Required fields are marked *