[英]Type error: Undefined is not a function (esri map)
將dojo代碼升級到2.x后,我得到一個非常奇怪的錯誤。 該函數定義為:
var map; //Globally defined
Require(["esri/map", "esri/geometry/Point"], function(Map, Point) {
map = new Map("map", {infoWindow: popupWin, extent: initialExtent, sliderStyle: 'small', sliderPosition: "bottom-right", navigationMode: 'css-transforms'});
var a = (map.toMap(new Point(0, 0));
});
但是,當我在控制台中執行map.toMap()函數時,它可以正常工作。 有誰知道我要去哪里錯了? 真是令人困惑...
您是否嘗試過包括domReady! ? 這將導致函數等待,直到DOM被加載。
require([
"esri/map",
"esri/geometry/Point",
"dojo/domReady!"
], function(){
// will not run until DOM is finished loading
});
否則,可能是您的包含尚未注冊,您可以通過將代碼包裝在dojo / ready中來解決。
require([
"esri/map",
"esri/geometry/Point",
"dojo/ready"
], function(map, Point, ready){
ready(function(){
// This function won't run until the DOM has loaded and other modules that register
});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.