【发布时间】:2019-05-05 13:58:43
【问题描述】:
我正在使用 Esri GIS 从地址加载中心位置。但我使用谷歌的地理编码器来获取经度和纬度。我被这个错误困住了:
TypeError: this.spatialReference is undefined
你对这个问题有什么想法吗? 这是我的代码:
require(["esri/map", "esri/geometry/Point", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/PictureMarkerSymbol", "esri/graphic", "esri/layers/GraphicsLayer", "dojo/domReady!" ],
function(Map, Point, SimpleMarkerSymbol, PictureMarkerSymbol, Graphic, GraphicsLayer) {
var point = new Point(0, 0, new esri.SpatialReference({ wkid: gisMap['wkid'] }));
map = new Map(mapHolder, {center: point,zoom: gisMap['zoomlevel']});
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': keyword}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude= results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
console.log(longitude+"|"+latitude);
if (status != google.maps.GeocoderStatus.ZERO_RESULTS) {
map.centerAt(new Point(longitude,latitude));
console.log(map);
} else {
console.log("No results found");
}
} else {
console.log("Something got wrong " + status);
}
});
});
【问题讨论】:
-
哪一行代码抛出了这个错误?你的代码从不使用
this,所以这是彩票 -
不确定,因为我已经有一段时间没有使用它了,但是您不必在您的需求中添加“esri/SpatialReference”,然后像使用新的 SpatialReference 而不是新的 esri.SpatialReference 一样使用它?
标签: javascript arcgis esri