简体   繁体   English

Mapael + Raphael,无法初始化:“无法读取未定义的属性”

[英]Mapael + Raphael, can't be initialized : “cannot read property of undefined”

I'm trying to set up a map using Rapheal (v2.1.4) and Mapael (v1.1.0) plugins but I get this error : 我正在尝试使用Rapheal(v2.1.4)和Mapael(v1.1.0)插件设置地图,但出现此错误:

Uncaught TypeError: Cannot read property 'x' of undefined 未捕获的TypeError:无法读取未定义的属性“ x”

I don't understand where my error is 我不明白我的错误在哪里

DOM: DOM:

<div class="row">
    <div class="col-md-12">
        <div class="mapDepFr"></div>
    </div>
</div>

JS: JS:

<script src="{{ asset('js/raphael-min.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/jquery.mapael.js') }}" type="text/javascript"></script>
<script src="{{ asset('js/maps/france_departments.js') }}" type="text/javascript"></script>
    <script>
        $(".mapDepFr").mapael({
            map: { name: "france_departments", }

        });
    </script>

The mapDepFr div is placed before the Js part and all the js files are well loaded. 将mapDepFr div放在Js部分之前,并且所有js文件都已正确加载。

Where is my mistake ? 我的错误在哪里?

Tanks. 战车

You'll want to create the map after the DOM is loaded. 您需要在DOM加载后创建地图。

<script>
  $(function(){ // jQuery shorthand for DOM ready
    $(".mapDepFr").mapael({
      map: { name: "france_departments", }
    });
  });
</script>

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

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