参考错误 Ymaps is not defined
Reference error Ymaps is not defined
带有 Yandex 地图定义的 JS 文件:
public class Ymap {
public static final native Object getMap() /*-{
var myMap;
function init() {
// Creating an instance of the map and binding it to the container with the specified ID
// ("map").
myMap = new ymaps.Map('map', {
center : [ 55.010251, 82.958437 ], // Новосибирск
zoom : 9
}, {
searchControlProvider : 'yandex#search'
});
}
YMaps.load(init);
return myMap;
}-*/;
}
然后我在另一个文件中调用此 js 代码以将地图放置在 smartgwt 布局中。
Canvas canvas = new Canvas();
canvas.addChild((Canvas)Ymap.getMap());
layoutRight.addMember(canvas);
但在浏览器中我收到引用错误:Ymaps 未定义
Yandex 地图 API 无法在我的项目中加载到一个文件中,然后在另一个文件中使用。因此我必须创建一个 html 文件。在其中的 header 中,我加载了 api 并在脚本中使用 api 编写了 js 代码。我使用 GET 请求发送的 java 文件中的所有必要参数。 html 文件的结果通过其 setContentsUrl 方法放置在我的 smartgwt HTMLPane 中。
带有 Yandex 地图定义的 JS 文件:
public class Ymap {
public static final native Object getMap() /*-{
var myMap;
function init() {
// Creating an instance of the map and binding it to the container with the specified ID
// ("map").
myMap = new ymaps.Map('map', {
center : [ 55.010251, 82.958437 ], // Новосибирск
zoom : 9
}, {
searchControlProvider : 'yandex#search'
});
}
YMaps.load(init);
return myMap;
}-*/;
}
然后我在另一个文件中调用此 js 代码以将地图放置在 smartgwt 布局中。
Canvas canvas = new Canvas();
canvas.addChild((Canvas)Ymap.getMap());
layoutRight.addMember(canvas);
但在浏览器中我收到引用错误:Ymaps 未定义
Yandex 地图 API 无法在我的项目中加载到一个文件中,然后在另一个文件中使用。因此我必须创建一个 html 文件。在其中的 header 中,我加载了 api 并在脚本中使用 api 编写了 js 代码。我使用 GET 请求发送的 java 文件中的所有必要参数。 html 文件的结果通过其 setContentsUrl 方法放置在我的 smartgwt HTMLPane 中。