Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8117101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:03:15+00:00 2026-06-06T04:03:15+00:00

So by now we’re familiar with adding shapes to a Google map with the

  • 0

So by now we’re familiar with adding shapes to a Google map with the v3 API:

$j('#map').gmap('addShape', 'Circle', { 
    'strokeWeight': 0, 
    'fillColor': "#008595", 
    'fillOpacity': 0.25, 
    'center': result[0].geometry.location, 
    'radius': 1500, 
    'clickable': false 
});

The above code will create a circle and shade it with fill #008595. Is there any way to inversely shade a map? I would like the entire world to be shaded/filled at half opacity except for a hole where my markers are. Possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:03:16+00:00Added an answer on June 6, 2026 at 4:03 am

    you need to define a polygon that covers the whole world and has a hole in it, you can’t do it with the "Circle" or "Rectangle" shapes, it has to be a polygon with (at least) two paths.

    here is an example

    screen shot

    related questions:

    • Change map opacity outside circle of Google Maps JavaScript API v3
    • Highlight polygon and tint rest of map using Google Maps

    code snippet:

    // This example creates circles on the map, representing
    // populations in the United States.
    
    // First, create an object containing LatLng and population for each city.
    var citymap = {};
    citymap['chicago'] = {
      center: new google.maps.LatLng(41.878113, -87.629798),
      population: 2842518
    };
    citymap['newyork'] = {
      center: new google.maps.LatLng(40.714352, -74.005973),
      population: 8143197
    };
    citymap['losangeles'] = {
      center: new google.maps.LatLng(34.052234, -118.243684),
      population: 3844829
    };
    var cityCircle;
    var bounds = new google.maps.LatLngBounds();
    
    function drawCircle(point, radius, dir) {
      var d2r = Math.PI / 180; // degrees to radians 
      var r2d = 180 / Math.PI; // radians to degrees 
      var earthsradius = 3963; // 3963 is the radius of the earth in miles
      var points = 32;
    
      // find the raidus in lat/lon 
      var rlat = (radius / earthsradius) * r2d;
      var rlng = rlat / Math.cos(point.lat() * d2r);
    
      var extp = new Array();
      if (dir == 1) {
        var start = 0;
        var end = points + 1
      } // one extra here makes sure we connect the ends
      else {
        var start = points + 1;
        var end = 0
      }
      for (var i = start;
        (dir == 1 ? i < end : i > end); i = i + dir) {
        var theta = Math.PI * (i / (points / 2));
        ey = point.lng() + (rlng * Math.cos(theta)); // center a + radius x * cos(theta) 
        ex = point.lat() + (rlat * Math.sin(theta)); // center b + radius y * sin(theta) 
        extp.push(new google.maps.LatLng(ex, ey));
        bounds.extend(extp[extp.length - 1]);
      }
      return extp;
    }
    
    function initialize() {
      // Create the map.
      var mapOptions = {
        zoom: 4,
        center: new google.maps.LatLng(37.09024, -95.712891),
        mapTypeId: google.maps.MapTypeId.TERRAIN
      };
    
      var map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions);
    
      var outerbounds = [
        new google.maps.LatLng(85, 180),
        new google.maps.LatLng(85, 90),
        new google.maps.LatLng(85, 0),
        new google.maps.LatLng(85, -90),
        new google.maps.LatLng(85, -180),
        new google.maps.LatLng(0, -180),
        new google.maps.LatLng(-85, -180),
        new google.maps.LatLng(-85, -90),
        new google.maps.LatLng(-85, 0),
        new google.maps.LatLng(-85, 90),
        new google.maps.LatLng(-85, 180),
        new google.maps.LatLng(0, 180),
        new google.maps.LatLng(85, 180)
      ];
      var populationOptions = {
        strokeColor: '#FF0000',
        strokeOpacity: 0.8,
        strokeWeight: 2,
        fillColor: '#FF0000',
        fillOpacity: 0.35,
        map: map,
        paths: [outerbounds, drawCircle(citymap['newyork'].center, 10, -1)]
      };
      // Add the circle for this city to the map.
      cityCircle = new google.maps.Polygon(populationOptions);
      map.fitBounds(bounds);
    }
    
    google.maps.event.addDomListener(window, 'load', initialize);
    html,
    body,
    #map-canvas {
      height: 100%;
      margin: 0px;
      padding: 0px
    }
    <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
    <div id="map-canvas"></div>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now I am working on a project about google adwords. I try to follow
Now, I'm familiar with templates and I'm somewhat familiar with things like SFINAE, and
Now that Google Drive has launched I wondered if it is possible to integrate
Now, before you say it: I did Google and my hbm.xml file is an
Now that FDT no longer supports fdt.launch.Application from AIR projects, how do you go
Now as you can see the query I have used above if a keyword
Now my bars located on frame thanks to nDockBarID = AFX_IDW_DOCKBAR_LEFT ForcesBar* m_forcesBar[3]; for
Now I have another problem with WCF server/client. I have a method: bool spr_wiersz(int
Now I am exceptionally new to network programming so tell me if this is
Now I am on a dilemma about whether to create a separate folder for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.