Javascript 在google maps v3(MVC对象)中调整圆的大小
我从这里获取了示例代码---> 我还添加了一些代码,以获得最大和最小的调整范围。。 我已成功使圆在这两个范围内停止,但调整大小标记不会停止,例如圆 我唯一改变的就是这个Javascript 在google maps v3(MVC对象)中调整圆的大小,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我从这里获取了示例代码---> 我还添加了一些代码,以获得最大和最小的调整范围。。 我已成功使圆在这两个范围内停止,但调整大小标记不会停止,例如圆 我唯一改变的就是这个 RadiusWidget.prototype.setDistance = function() { // As the sizer is being dragged, its position changes. Because the // RadiusWidget's sizer_position is bound
RadiusWidget.prototype.setDistance = function() {
// As the sizer is being dragged, its position changes. Because the
// RadiusWidget's sizer_position is bound to the sizer's position, it will
// change as well.
var pos = this.get('sizer_position');
var center = this.get('center');
var distance = this.distanceBetweenPoints_(center, pos);
// Set the distance property for any objects that are bound to it
this.set('distance', distance);
};
对此
RadiusWidget.prototype.setDistance = function() {
// As the sizer is being dragged, its position changes. Because the
// RadiusWidget's sizer_position is bound to the sizer's position, it will
// change as well.
var min=0.5;
var max=15;
var pos = this.get('sizer_position');
var center = this.get('center');
var distance = this.distanceBetweenPoints_(center, pos);
if (distance < min){ distance = min;}
if (distance > max){distance = max;}
// Set the distance property for any objects that are bound to it
this.set('distance', distance);
};
RadiusWidget.prototype.setDistance=function(){
//当拖动sizer时,其位置会发生变化
//RadiusWidget的sizer_位置绑定到sizer的位置,它将
//也要改变。
var最小值=0.5;
var max=15;
var pos=this.get('sizer_position');
var center=this.get('center');
var距离=点之间的距离(中心,位置);
如果(距离最大值){distance=max;}
//为绑定到它的任何对象设置距离特性
这个。设置('距离',距离);
};
如果我在“拖动”事件侦听器中设置距离限制,它对我更有效:
google.maps.event.addListener(sizer, 'drag', function() {
// As the sizer is being dragged, its position changes. Because the
// RadiusWidget's sizer_position is bound to the sizer's position, it will
// change as well.
var min=0.5;
var max=15;
var pos = me.get('sizer_position');
var center = me.get('center');
var distance = google.maps.geometry.spherical.computeDistanceBetween(center, pos)/1000;
if (distance < min) {
me.set('sizer_position', google.maps.geometry.spherical.computeOffset(center,min*1000,google.maps.geometry.spherical.computeHeading(center,pos)));
} else if (distance > max){
me.set('sizer_position', google.maps.geometry.spherical.computeOffset(center,max*1000,google.maps.geometry.spherical.computeHeading(center,pos)));
}
// Set the circle distance (radius)
me.setDistance();
});
};
google.maps.event.addListener(sizer'drag',function(){
//当拖动sizer时,其位置会发生变化
//RadiusWidget的sizer_位置绑定到sizer的位置,它将
//也要改变。
var最小值=0.5;
var max=15;
var pos=me.get('sizer_position');
var center=me.get('center');
var distance=google.maps.geometry.Spheremic.ComputedDistanceBeween(center,pos)/1000;
如果(距离<分钟){
me.set('sizer_position',google.maps.geometry.spheremic.computeOffset(中心,最小*1000,google.maps.geometry.spheremic.computeHeading(中心,位置));
}否则,如果(距离>最大值){
me.set('sizer_position',google.maps.geometry.spheremic.computeOffset(中心,max*1000,google.maps.geometry.spheremic.computeHeading(中心,位置));
}
//设置圆距离(半径)
me.setDistance();
});
};
注意:我使用了来计算距离),需要包括该库
噢,非常感谢!这对我来说太好了!好好干!再次感谢!