0

Please assist. Ive googled and gone through stack overflow but am unable to find this information anywhere. Is there a way to show only a specific continent, in my case Africa and hide all other unwanted continents in google maps. These maps shouldn't show at all. I came across this article -> Can i hide land masses with Google Maps API

But there is no specific example.

I am using Google Maps API 3.

Currently I have:

<script type="text/javascript"
                src="https://maps.googleapis.com/maps/api/js?key=mykey&sensor=true">
        </script>
        <script type="text/javascript">
            function initialize() {

                //Implement map styling
                var styles = [
                    {
                        "stylers": [
                            {"visibility": "simplified"}
                        ]
                    }
                ];


                var styledMap = new google.maps.StyledMapType(styles, {name: "MyMap"});

                var mapOptions = {
                    center: new google.maps.LatLng(0.972198, 23.994141),
                    zoom: 3,
                    mapTypeId: google.maps.MapTypeId.ROADMAP,
                    panControl: false,
                    zoomControl: false,
                    streetViewControl: false,
                    mapTypeControl: false,
                    mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style'],
                    draggable: false,
                    scrollwheel: false,
                    panControl: false

                };


                var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);

                //Load kml of africa
                var kmlMap = new google.maps.KmlLayer('http://myOverLay.kmz',
                        {
                            //suppressInfoWindows: false,
                            //map: map,
                            preserveViewport: true
                        });
                kmlMap.setMap(map);

                //map.mapTypes.set();

                //Associate the styled map with the MapTypeId and set it to display.
                map.mapTypes.set('map_style', styledMap);
                map.setMapTypeId('map_style');

            }


            google.maps.event.addDomListener(window, 'load', initialize);
        </script> 
Community
  • 1
  • 1
Dean
  • 1,226
  • 2
  • 20
  • 39

2 Answers2

0

One option:

  1. Cover the whole world except for a hole over your continent of choice. example of concept (US state of Virginia)
  2. Limit the zoom and the bounds to prevent the map from going too far from showing that continent. description of how to limit the viewable area
Community
  • 1
  • 1
geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • If I had existing KML outlining my continent, would i be able to invert automatically or would I have to manually recreate the KML? @geocodezip – Dean May 20 '13 at 21:57
  • That depends on how you are displaying it. The way you create "holes" in polygons is you have the outer polygon (the whole world) wind the opposite direction of the inner polygon (your continent). You can try it and see if it works, if it doesn't work at first reverse the winding direction of the outer polygon. – geocodezip May 20 '13 at 22:43
0

Doesnt seem possible. Ended up using image mapster

Dean
  • 1,226
  • 2
  • 20
  • 39