带有 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 is not defined