【问题标题】:Update google heatmap更新谷歌热图
【发布时间】:2017-10-13 08:22:01
【问题描述】:

我有 asp.net 项目

我在 View 中有谷歌热图,需要更新它

这是客户端的脚本代码。

@section scripts {
<script async defer
        src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCea6mL2cqwVid2ESIjuJ0C31RbNVQNPY0&libraries=visualization&callback=initMap">
</script>
<script type="text/javascript">



    var map, heatmap;

    function initMap() {
        map = new google.maps.Map(document.getElementById('map'),
            {
                zoom: 13,
                center: { lat: 55.752622, lng: 37.617567 },
                mapTypeId: 'satellite'
            });
        getPoints();
    }

    function toggleHeatmap() {
        heatmap.setMap(heatmap.getMap() ? null : map);
    }

    function changeGradient() {
        var gradient = [
            'rgba(0, 255, 255, 0)',
            'rgba(0, 255, 255, 1)',
            'rgba(0, 191, 255, 1)',
            'rgba(0, 127, 255, 1)',
            'rgba(0, 63, 255, 1)',
            'rgba(0, 0, 255, 1)',
            'rgba(0, 0, 223, 1)',
            'rgba(0, 0, 191, 1)',
            'rgba(0, 0, 159, 1)',
            'rgba(0, 0, 127, 1)',
            'rgba(63, 0, 91, 1)',
            'rgba(127, 0, 63, 1)',
            'rgba(191, 0, 31, 1)',
            'rgba(255, 0, 0, 1)'
        ];
        heatmap.set('gradient', heatmap.get('gradient') ? null : gradient);
    }

    function changeRadius() {
        heatmap.set('radius', heatmap.get('radius') ? null : 20);
    }

    function changeOpacity() {
        heatmap.set('opacity', heatmap.get('opacity') ? null : 0.2);
    }


    //make loading
    function getPoints() {

        var taxiData = [
            new google.maps.LatLng(37.782551, -122.445368)

        ];
         pointArray = new google.MAX_CUBE_MAP_TEXTURE_SIZE.MVCArray(taxiData);
        heatmap = new google.maps.visualization.HeatmapLayer({
            data: pointArray
        });
        heatmap.setMap(map);


    }
</script>

}

我尝试用这种方法更新地图

函数 getPoints()

但我得到错误

未捕获的类型错误:无法读取未定义的属性“MVCArray”

在这一行

 pointArray = new google.MAX_CUBE_MAP_TEXTURE_SIZE.MVCArray(taxiData);

我该如何解决这个问题?

谢谢你的帮助

【问题讨论】:

    标签: javascript c# asp.net asp.net-mvc google-maps-api-3


    【解决方案1】:
    google.MAX_CUBE_MAP_TEXTURE_SIZE.MVCArray
    

    应该是:

    google.maps.MVCArray
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-31
      • 1970-01-01
      • 1970-01-01
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多