Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.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 如何在AngularJS中使用amMap?_Javascript_Angularjs_Amcharts_Ammap - Fatal编程技术网

Javascript 如何在AngularJS中使用amMap?

Javascript 如何在AngularJS中使用amMap?,javascript,angularjs,amcharts,ammap,Javascript,Angularjs,Amcharts,Ammap,我在Web应用程序中使用amCharts库来呈现所有图表。它们工作正常,但我需要在页面上添加一个mapChart。我对地图图表的熟悉程度不如其他图表,因为使用它似乎需要与其他图表不同的方法 请查看我的代码设置,并查看代码中可能出现的错误 以下代码将库添加到索引文件中: <script type="text/javascript" src="bower_components/ammap3/ammap/ammap.js"> </script> <script type=

我在Web应用程序中使用
amCharts
库来呈现所有图表。它们工作正常,但我需要在页面上添加一个
mapChart
。我对地图图表的熟悉程度不如其他图表,因为使用它似乎需要与其他图表不同的方法

请查看我的代码设置,并查看代码中可能出现的错误

以下代码将库添加到索引文件中:

<script type="text/javascript" src="bower_components/ammap3/ammap/ammap.js">
</script>
<script type="text/javascript" 
src="bower_components/ammap3/ammap/maps/js/worldLow.js"></script>

我这样写控制器:

.controller('MapChartCtrl', ['$scope', '$timeout', function ($scope, $timeout) {

$scope.amChartOptions = {
          type: 'map',
          theme: 'blur',
          zoomControl: { zoomControlEnabled: false, panControlEnabled: false 
},

data: {
    map: 'worldLow',
    zoomLevel: 3.5,
    zoomLongitude: 10,
    zoomLatitude: 52,

    areas: [
      { title: 'Austria', id: 'AT', color: '#62bbb2', customData: '1 
                244', groupId: '1'},
      { title: 'Ireland', id: 'IE', color: '#62bbb2', customData: '1 
                342', groupId: '1'},
      { title: 'Denmark', id: 'DK', color: '#62bbb2', customData: '1 
                973', groupId: '1'},
      { title: 'Finland', id: 'FI', color: '#62bbb2', customData: '1 
                573', groupId: '1'},
      { title: 'Sweden', id: 'SE', color: '#62bbb2', customData: '1 
                084', groupId: '1'},
      { title: 'Great Britain', id: 'GB', color: '#62bbb2', 
                customData: '1 452', groupId: '1'}
    ]
},

areasSettings: {
    rollOverOutlineColor: "#62bbb2",
    rollOverColor: "#62bbb2",
    alpha: 0.8,
    unlistedAreasAlpha: 0.2,
    unlistedAreasColor: "#bfbfbf",
    balloonText: '[[title]]: [[customData]] users'},
    categoryField: "title",

    legend: {
        width: '100%',
        marginRight: 27,
        marginLeft: 27,
        equalWidths: false,
        backgroundAlpha: 0.3,
        backgroundColor: "#bfbfbf",
        borderColor: "#bfbfbf",
        borderAlpha: 1,
        top: 362,
        left: 0,
        horizontalGap: 10,
        data: [
        {
          title: 'over 1 000 users',
          color: '#62bbb2'
        },
        {
          title: '500 - 1 000 users',
          color: '#b9f2a1'
        },
        {
          title: '100 - 500 users',
          color: '#ed7878'
        },
        {
          title: '0 - 100 users',
          color: '#e1e1e1'
        }
    ]
},

export: {
    enabled: true
},

pathToImages: 'bower_components/amcharts/dist/amcharts/images/'
}}])




   <div class="panel-heading">Map Chart</div>
 <div ng-controller="MapChartCtrl" style="height: 400px; width: 100%;">
 <am-chart id="MapChart" options="amChartOptions"></am-chart>
 </div> 
.controller('MapChartCtrl',['$scope','$timeout',函数($scope,$timeout){
$scope.amChartOptions={
键入:“映射”,
主题:“模糊”,
zoomControl:{zoomControl可启用:false,PanControl可启用:false
},
数据:{
地图:“世界之路”,
zoomLevel:3.5,
动物长度:10,
动物死亡率:52,
领域:[
{标题:'Austria',id:'AT',颜色:'#62bbb2',客户数据:'1
244',组ID:'1'},
{标题:'Ireland',id:'IE',颜色:'#62bbb2',客户数据:'1
342',组ID:'1'},
{标题:“丹麦”,id:“DK”,颜色:“#62bbb2”,客户数据:'1
973',组ID:'1'},
{标题:'Finland',id:'FI',颜色:'#62bbb2',客户数据:'1
573',组ID:'1'},
{标题:“瑞典”,id:“SE”,颜色:“#62bbb2”,客户数据:'1
084',组ID:'1'},
{标题:“大不列颠”,id:“GB”,颜色:“#62bbb2”,
customData:'1 452',groupId:'1'}
]
},
区域设置:{
展期大纲颜色:“62bbb2”,
滚动颜色:#62bbb2“,
阿尔法:0.8,
无柄α:0.2,
未显示颜色:“#bfbf”,
气球文本:'[[title]]:[[customData]]users'},
类别字段:“标题”,
图例:{
宽度:“100%”,
marginRight:27,
marginLeft:27,
等宽:false,
背景α:0.3,
背景色:“#bfbf”,
边框颜色:“#bfbf”,
阿尔法:1,
排名:362,
左:0,,
水平差距:10,
数据:[
{
标题:“超过1000名用户”,
颜色:“#62bbb2”
},
{
标题:“500-1000用户”,
颜色:“#b9f2a1”
},
{
标题:“100-500用户”,
颜色:“#ed7878”
},
{
标题:“0-100个用户”,
颜色:“#e1e1”
}
]
},
出口:{
已启用:true
},
路径图像:“bower_组件/amcharts/dist/amcharts/images/”
}}])
地图

控制器:

.directive('myElem',
 function () {
   return {
       restrict: 'E',
       replace:true,

       template: '<div id="chartdiv" style="min-width: 310px; height: 400px; margin: 0 auto"></div>',
       link: function (scope, element, attrs) {

            var chart = false;

            var initChart = function() {
              if (chart) chart.destroy();
              var config = scope.config || {};
              var targetSVG = "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z";
               chart = AmCharts.makeChart("chartdiv", {
                   type: "map",
                   projection: "winkel3",
                   theme: "light",
                   imagesSettings: {
                     rollOverColor: "#089282",
                     rollOverScale: 3,
                     selectedScale: 3,
                     selectedColor: "#089282",
                     color: "#13564e"
                   },

                   areasSettings: {
                     unlistedAreasColor: "#15A892",
                     outlineThickness: 0.1
                   },

                   dataProvider: {
                     map: "worldLow",
                     images: [ {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Vienna",
                       latitude: 48.2092,
                       longitude: 16.3728
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Minsk",
                       latitude: 53.9678,
                       longitude: 27.5766
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Brussels",
                       latitude: 50.8371,
                       longitude: 4.3676
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Sarajevo",
                       latitude: 43.8608,
                       longitude: 18.4214
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Sofia",
                       latitude: 42.7105,
                       longitude: 23.3238
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Zagreb",
                       latitude: 45.8150,
                       longitude: 15.9785
                     }
                     ]
                   },
                   export: {
                     enabled: true
                   },

                  pathToImages: 'bower_components/amcharts/dist/amcharts/images/'
        });


            };
            initChart();

       }         
   }
   });
<my-elem></my-elem>
.directive('myElem',
函数(){
返回{
限制:'E',
替换:正确,
模板:“”,
链接:函数(范围、元素、属性){
var图=假;
var initChart=函数(){
if(chart)chart.destroy();
var config=scope.config | |{};
9.9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1.5,7.067,12.5,9z”;
chart=AmCharts.makeChart(“chartdiv”{
键入:“地图”,
投影:“winkel3”,
主题:“光”,
图像设置:{
滚动颜色:#089282“,
滚动刻度:3,
选择比例:3,
选择颜色:#089282“,
颜色:“13564e”
},
区域设置:{
未分类颜色:“15A892”,
大纲厚度:0.1
},
数据提供者:{
地图:“世界之路”,
图像:[{
svgPath:targetSVG,
zoomLevel:5,
比例:0.5,
标题:“维也纳”,
纬度:48.2092,
经度:16.3728
}, {
svgPath:targetSVG,
zoomLevel:5,
比例:0.5,
标题:“明斯克”,
纬度:53.9678,
经度:27.5766
}, {
svgPath:targetSVG,
zoomLevel:5,
比例:0.5,
标题:“布鲁塞尔”,
纬度:50.8371,
经度:4.3676
}, {
svgPath:targetSVG,
zoomLevel:5,
比例:0.5,
标题:“萨拉热窝”,
纬度:43.8608,
经度:18.4214
}, {
svgPath:targetSVG,
zoomLevel:5,
比例:0.5,
标题:“索菲亚”,
纬度:42.7105,
经度:23.3238
}, {
svgPath:targetSVG,
zoomLevel:5,
比例:0.5,
标题:“萨格勒布”,
纬度:45.8150,
经度:15.9785
}
]
},
出口:{
已启用:true
},
路径图像:“bower_组件/amcharts/dist/amcharts/images/”
});
};
initChart();
}         
}
});
HTML:

.directive('myElem',
 function () {
   return {
       restrict: 'E',
       replace:true,

       template: '<div id="chartdiv" style="min-width: 310px; height: 400px; margin: 0 auto"></div>',
       link: function (scope, element, attrs) {

            var chart = false;

            var initChart = function() {
              if (chart) chart.destroy();
              var config = scope.config || {};
              var targetSVG = "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z";
               chart = AmCharts.makeChart("chartdiv", {
                   type: "map",
                   projection: "winkel3",
                   theme: "light",
                   imagesSettings: {
                     rollOverColor: "#089282",
                     rollOverScale: 3,
                     selectedScale: 3,
                     selectedColor: "#089282",
                     color: "#13564e"
                   },

                   areasSettings: {
                     unlistedAreasColor: "#15A892",
                     outlineThickness: 0.1
                   },

                   dataProvider: {
                     map: "worldLow",
                     images: [ {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Vienna",
                       latitude: 48.2092,
                       longitude: 16.3728
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Minsk",
                       latitude: 53.9678,
                       longitude: 27.5766
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Brussels",
                       latitude: 50.8371,
                       longitude: 4.3676
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Sarajevo",
                       latitude: 43.8608,
                       longitude: 18.4214
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Sofia",
                       latitude: 42.7105,
                       longitude: 23.3238
                     }, {
                       svgPath: targetSVG,
                       zoomLevel: 5,
                       scale: 0.5,
                       title: "Zagreb",
                       latitude: 45.8150,
                       longitude: 15.9785
                     }
                     ]
                   },
                   export: {
                     enabled: true
                   },

                  pathToImages: 'bower_components/amcharts/dist/amcharts/images/'
        });


            };
            initChart();

       }         
   }
   });
<my-elem></my-elem>


html代码映射图在哪里我解决了这个问题,我已经通过