javascript - Darkened map around light area circle where marker resides in Google Map -


i'm trying darken of map except region inside circle, have marker. inside want map light. i'm trying play around setting lightness of map, not sure if that's correct approach? in code below , in fiddle can create dark map, can't figure out how make area inside circle light. see picture @ bottom example of i'm trying do.

<!doctype html>  <html xmlns="http://www.w3.org/1999/xhtml">    <head>    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>    <script type="text/javascript">      var $styles = [{        stylers: [{          lightness: -60        }]      }];              var mapoptions = {        zoom: "",        zoomcontrol: "",        center: "",        disabledefaultui: "",        draggable: "",        styles: $styles,        disabledoubleclickzoom: ""      }        var geocoder = new google.maps.geocoder();        function geocodeposition(pos) {        geocoder.geocode({          latlng: pos        }, function(responses) {          if (responses && responses.length > 0) {            updatemarkeraddress(responses[0].formatted_address);          } else {            updatemarkeraddress('cannot determine address @ location.');          }        });      }        function updatemarkerstatus(str) {        document.getelementbyid('markerstatus').innerhtml = str;      }        function updatemarkerposition(latlng) {        document.getelementbyid('info').innerhtml = [          latlng.lat(),          latlng.lng()        ].join(', ');      }        function updatemarkeraddress(str) {        document.getelementbyid('address').innerhtml = str;      }        function initialize() {        var latlng = new google.maps.latlng(37.9, -122);        var map = new google.maps.map(document.getelementbyid('mapcanvas'), {          zoom: 14,          center: latlng,          maptypeid: google.maps.maptypeid.roadmap,          styles: $styles        });        var marker = new google.maps.marker({          position: latlng,          title: 'point a',          map: map,          draggable: true        });          var circleoptions = {          //strokecolor: '#ff0000',          //strokeopacity: 0.8,          //strokeweight: 2,          //fillcolor: "", //'#ff0000',          //fillopacity: 0.35,          map: map,          center: new google.maps.latlng(37.9, -122),          radius: math.sqrt(5) * 100        };        var circle = new google.maps.circle(circleoptions);          marker.bindto('position', map, 'center');          // update current position info.        updatemarkerposition(latlng);        geocodeposition(latlng);          // add dragging event listeners.        google.maps.event.addlistener(marker, 'dragstart', function() {          updatemarkeraddress('dragging...');        });          google.maps.event.addlistener(marker, 'drag', function() {          updatemarkerstatus('dragging...');          updatemarkerposition(marker.getposition());        });          google.maps.event.addlistener(marker, 'dragend', function() {          updatemarkerstatus('drag ended');          geocodeposition(marker.getposition());        });      }         // onload handler fire off app.      google.maps.event.adddomlistener(window, 'load', initialize);    </script>  </head>    <body>    <style>      #mapcanvas {        width: 500px;        height: 400px;        float: left;      }      #infopanel {        float: left;        margin-left: 10px;      }      #infopanel div {        margin-bottom: 5px;      }    </style>      <div id="mapcanvas"></div>    <div id="infopanel">      <b>marker status:</b>      <div id="markerstatus"><i>click , drag marker.</i>      </div>      <b>current position:</b>      <div id="info"></div>      <b>closest matching address:</b>      <div id="address"></div>    </div>  </body>    </html>

i want map this.

enter image description here


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -