Categories

Wednesday, November 20, 2024
#919814419350 therichposts@gmail.com
Google MapGoogle Map ApiJavascript

How to show Google Map for particular Country with selected Provinces?

Hello to all, welcome to therichpost.com. Today In this post, I will show, How to show Google Map for particular Country with selected Provinces?

If you new in Google map or you want know more about it then you can check my posts related to Google Maps.

This post is very interesting and I am hoping, you will all like this also very much.

How to show Google Map for particular Country with selected Provinces

Here is the working code and you can add this into your html file:

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {
        'packages':['geomap'],
        // Note: you will need to get a mapsApiKey for your project.
        // See: https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings
        'mapsApiKey': 'AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'
      });
      google.charts.setOnLoadCallback(drawRegionsMap);

      function drawRegionsMap() {
        var data = google.visualization.arrayToDataTable([
            ['Regions', 'Popularity'],
            ['New York', 200],
            ['Texas', 500],
            ['California', 600]
            
        ]);

         var options = {};
         options['region'] = 'US';
         options['resolution'] = 'provinces';
         

        var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="regions_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

If you have any query or you want more advance code related to this, then you can comment below or ask question.

Thank you,

Harjas,

TheRichPost

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

15 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.