Working with Google maps

Google maps with geolocation for tracking the user location and get content accordingly.

How to get the country name using latitude & longitude?



$output= json_decode($geocode);

           if(in_array("country", $cn))
            $country= $output->results[0]->address_components[$j]->long_name;
echo $country;

How to get current location with movable marker and get the value in a text field?


<div id="map"></div>
      function initMap() {
          var myLatLng = {lat: -37.706291, lng: 144.91165};

        var mapDiv = document.getElementById('map');
        var map = new google.maps.Map(mapDiv, {
          center: myLatLng,
          zoom: 14

        var marker = new google.maps.Marker({


        google.maps.event.addListener(marker, 'dragend', function (event) {
            document.getElementById("latbox").value = this.getPosition().lat();
            document.getElementById("lngbox").value = this.getPosition().lng();

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

    <div id="latbox"><input type="text" id="lngbox" /></div>


About me

I'm Subash Thapa (web developer, freelancer, designer).

Web development has been my passion from the day I started using computer. I can help you from the first stage of website i.e designing, programming(developing) till the last stage or deployment, including domain name registration and hosting.

I would love to get engaged in any type of website to design, develop or maintenance.