1

With reference to the answer of Mika in this question;

Is there a way to display a single country in Google map? It should be only one country, not parts from other countries included1

Is there a way i could enable clicking, dragging, scrolling with only US country in the map?

I had been trying to do it. But it shows a blank image with no error as follows:

Blank Map

Following is the code that i have modified from the above answer.

  var myLatlng = new google.maps.LatLng(41.850033, -87.6500523);

            var myOptions = {
                //zoom: 3,
                center: myLatlng,
                //mapTypeId: google.maps.MapTypeId.ROADMAP,
                zoom: 5,
                center: myLatlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP,

                styles: [
                    {
                        "featureType": "water",
                        "elementType": "geometry",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "landscape",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "road",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "administrative",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "poi",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "featureType": "administrative",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }, {
                        "elementType": "labels",
                        "stylers": [
                          { "visibility": "off" }
                        ]
                    }
                ]

            };

  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

What is it that i am missing? Any help would be highly appreciated.

Sana Ahmed
  • 462
  • 3
  • 25
  • I did create a map. Please see my edit – Sana Ahmed Jun 15 '17 at 05:59
  • 1
    By the way. Did you notice that the map where you copied this code from, the overlay is actually wrong? Also, your code doesn't add anything to the map (like the code you copied does) so why would you expect something to be visible if you've removed everything – Jaromanda X Jun 15 '17 at 06:02
  • I don't know of any way within google-maps api to only show one country on a map. You could do this, with vectors and another layer on top of the map. There was a project out of Mexico (I believe) doing something similar a couple years ago. You could also restrict the scrolling bounds as detailed here: https://stackoverflow.com/questions/3125065/how-do-i-limit-panning-in-google-maps-api-v3 – admcfajn Jun 15 '17 at 06:03
  • Jaromanda : I actually did a little edit to the code to enable dragging, scrolling bounded to USA. That is why it has some changes from where i copied. – Sana Ahmed Jun 15 '17 at 06:06

0 Answers0