繁体   English   中英

在Google地图上绘制圆圈和缩放级别问题

[英]Plotting Circles on a Google Map and issues with zoom level

我正在使用他们的Circle API在Google地图上绘制一些点https://developers.google.com/maps/documentation/javascript/examples/circle-simple

我遇到的问题是,并非所有点都以预定义的缩放级别4出现在地图上,如果我再放大一个级别,则它们确实会出现。 无论如何,即使在很远的变焦下也能使它们显示出来吗?

这是将标记添加到地图的代码:

addMarker: function(opts) {
  var gLatLng = this.gLatLng(opts);
  var radius = opts.population / 20;
  var self = this;

  this._configure_circle(radius);

  var circle = {
      strokeColor: this.color,
      strokeOpacity: 0.8,
      strokeWeight: this.stroke,
      fillColor: this.color,
      fillOpactiy: 1,
      map: this.map,
      center: gLatLng,
      radius: this.radius
  }
  var gCirle = new google.maps.Circle(circle);
  gCirle.setValues({_id: opts._id});
  this.markers.push(gCirle);

  google.maps.event.addListener(gCirle, 'click', function(event){
    self.map.setZoom(8);
    self.map.setCenter(new google.maps.LatLng(gCirle.getCenter().lat(), gCirle.getCenter().lng()));
    Session.set('currentMapArea', gCirle.get('_id'));
  });

  return gCirle;
},
_configure_circle: function(num) {
    if(num > 4000) {
        this.stroke = 50;
        this.color = '#66FF00'
        this.radius = num + 300;
    } else if(num <= 4000 && num > 3400) {
        this.stroke = 25;
        this.color = '#44E030';
        this.radius = num + 200;
    } else {
        this.stroke = 15;
        this.color = '#22DD60';
        this.radius = num;
    }
}

创建一个LatLngBounds ,用每个圆的边界扩展这些LatLngBounds,完成创建圆后,通过将LatLngBounds作为参数,调用地图的fitBounds方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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