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 'Hire an AI Product Manager: Skills, Salary and When You Need One', used as the featured image for hire ai product manager.

Hire an AI Product Manager: Skills, Salary and When You Need One

Your team can call a model API in an afternoon. Deciding what the AI feature should do, how good is…

Shafeeq Khan
November 14, 2026
Colour photograph illustrating the Eoxys blog post 'AEO for Local Businesses: Show Up in AI Mode and ChatGPT', used as the featured image for aeo for local businesses.

AEO for Local Businesses: Show Up in AI Mode and ChatGPT

“Best dental clinic near Vaishali Nagar open on Sunday.” “Which CA firm in Jaipur handles GST for small exporters?” People…

Shafeeq Khan
November 13, 2026
Colour photograph illustrating the Eoxys blog post 'MCP Server Development in 2026: Connect Your App to AI Agents', used as the featured image for MCP server development.

MCP Server Development in 2026: Connect Your App to AI Agents

Your customers and staff increasingly work inside ChatGPT, Claude, Copilot or an IDE agent. If those assistants cannot reach your…

Shafeeq Khan
November 12, 2026
,

Leave a Reply

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