Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在AngularUI谷歌地图上动态设置圆的半径_Javascript_Html_Angularjs_Google Maps - Fatal编程技术网

Javascript 在AngularUI谷歌地图上动态设置圆的半径

Javascript 在AngularUI谷歌地图上动态设置圆的半径,javascript,html,angularjs,google-maps,Javascript,Html,Angularjs,Google Maps,正如标题所示,我想在我的ui gmap-google-map元素上动态更改圆的半径,我尝试在文本框上使用onChange函数,要求这样的半径: HTML文件 <label for="distance" style="white-space: nowrap;">Enter a radius</label> <input type="text" required class="form-control" placeholder="Kilometers" ng-chang

正如标题所示,我想在我的
ui gmap-google-map
元素上动态更改圆的半径,我尝试在文本框上使用onChange函数,要求这样的半径:

HTML文件

<label for="distance" style="white-space: nowrap;">Enter a radius</label>
<input type="text" required class="form-control" placeholder="Kilometers" ng-change="setRadius()" name="distance" ng-model="map.marker.circle.radius" />
我还试图在“圆圈”数组中直接更改它,但同样没有结果

圆圈数组

$scope.circles = [
        {
            id: 1,
            center: {
                latitude: $scope.map.center.latitude,
                longitude: $scope.map.center.longitude
            },
            radius: $scope.circleRadius,
            stroke: {
                color: '#08B21F',
                weight: 2,
                opacity: 1
            },
            fill: {
                color: '#08B21F',
                opacity: 0.5
            },
            geodesic: true, // optional: defaults to false
            draggable: false, // optional: defaults to false
            clickable: false, // optional: defaults to true
            editable: false, // optional: defaults to false
            visible: true, // optional: defaults to true
            control: {}
        }
    ];
更改半径的功能

$scope.setRadius = function() {
    $scope.circleRadius = $scope.map.marker.circle.radius * 1000;
}
地图的HTML

<ui-gmap-google-map center="map.center" zoom="map.zoom">
<ui-gmap-window show="map.window.show" coords="map.window.model" options="map.window.options" closeclick="map.window.closeClick()">

</ui-gmap-window>

<ui-gmap-circle ng-repeat="c in circles track by c.id" center="c.center" stroke="c.stroke" fill="c.fill" radius="c.radius" visible="c.visible" geodesic="c.geodesic" editable="c.editable" draggable="c.draggable" clickable="c.clickable" control="c.control"></ui-gmap-circle>


我只是通过直接在圆数组中设置半径来解决这个问题(我觉得这不是最好的做法,但它很管用)

为了澄清:当距离改变时,我调用
setRadius()
函数,并通过调用设置半径的
$scope.circles[0].radius来设置半径

不需要其他任何东西

<ui-gmap-google-map center="map.center" zoom="map.zoom">
<ui-gmap-window show="map.window.show" coords="map.window.model" options="map.window.options" closeclick="map.window.closeClick()">

</ui-gmap-window>

<ui-gmap-circle ng-repeat="c in circles track by c.id" center="c.center" stroke="c.stroke" fill="c.fill" radius="c.radius" visible="c.visible" geodesic="c.geodesic" editable="c.editable" draggable="c.draggable" clickable="c.clickable" control="c.control"></ui-gmap-circle>