简体   繁体   中英

remove geolocation radius from google maps api v3

can anyone help me remove the radius on the geolocation marker? The code im using

  var map, GeoMarker;

  function initialize() {
    var mapOptions = {
      zoom: 17,
      center: new google.maps.LatLng(-34.397, 150.644),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById('map_canvas'),
        mapOptions);

    GeoMarker = new GeolocationMarker();
    GeoMarker.setCircleOptions({fillColor: '#808080'});

    google.maps.event.addListenerOnce(GeoMarker, 'position_changed', function() {
      map.setCenter(this.getPosition());
      map.fitBounds(this.getBounds());
    });

    google.maps.event.addListener(GeoMarker, 'geolocation_error', function(e) {
      alert('There was an error obtaining your position. Message: ' + e.message);
    });

    GeoMarker.setMap(map);

I tried removing GeoMarker.setCircleOptions({fillColor: '#808080'}); but it makes the circle much darker as a default.

Thanks for any help. (this is using https://www.npmjs.com/package/geolocation-marker plugin for geolocation)

If you don't want the circle, you should instead be using a google.maps.Marker instead. here is the link to the Google Maps Javascript API's relevant section on how to do so.

If you don't want circle visible, set it's opacity to 0 (and strokeWeight as well)

GeoMarker.setCircleOptions({
  fillOpacity: 0,
  strokeWeight: 0
});

proof of concept fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM