Google Maps API - Simple google map with draggable marker Example

By Hardik Savani | October 27, 2018 | Category : Javascript jQuery Google Map

Hi Artisan,

Are you looking for simple map for your website, if yes then you are a right place. i will create simple google map with marker using google api. you are also simply able to get lat and long from google map marker. if you are developing with wordpress, php, laravel then also easily use.

You have to simple copy below code and paste on your website. Also you can see demo from below button.



<!DOCTYPE html>



<title>Google Maps API - Simple google map with draggable marker Example</title>

<style type="text/css">

#map {

width: 100%;

height: 400px;





<h1>Google Maps API - Simple google map with draggable marker Example</h1>

<div id="map"></div>

<ul id="geoData">

<li>Latitude: <span id="lat-span"></span></li>

<li>Longitude: <span id="lon-span"></span></li>



function initMap() {

var myLatLng = {lat: 22.3038945, lng: 70.80215989999999};

var map = new google.maps.Map(document.getElementById('map'), {

center: myLatLng,

zoom: 13


var marker = new google.maps.Marker({

position: myLatLng,

map: map,

title: 'Hello World!',

draggable: true


google.maps.event.addListener(marker, 'dragend', function(marker) {

var latLng = marker.latLng;

document.getElementById('lat-span').innerHTML =;

document.getElementById('lon-span').innerHTML = latLng.lng();




<script src="" async defer></script>



I hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: