首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ESRI TypeError: this.spatialReference未定义

ESRI TypeError: this.spatialReference未定义
EN

Stack Overflow用户
提问于 2018-12-04 15:38:33
回答 1查看 806关注 0票数 0

我正在使用Esri GIS从地址加载中心位置。但我使用谷歌的地理编码器来获取经度和纬度。我遇到了这个错误:

代码语言:javascript
复制
TypeError: this.spatialReference is undefined

你对这个问题有什么想法吗?这是我的代码:

代码语言:javascript
复制
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);
                    }
                });
            });
EN

回答 1

Stack Overflow用户

发布于 2018-12-11 16:51:41

问题出在您初始化新的esri.SpatialReference时。您实际上并没有提供任何信息-- wkid是‘知名ID’的缩写,并且实际上不会向API传递任何信息。

因为您没有指定您正在使用的JS的版本(3.x和4.x是完全不同的),所以我不能发布正确的代码来向您展示应该如何做,但是这两个资源:https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-SpatialReference.html

https://developers.arcgis.com/javascript/3/jsapi/spatialreference-amd.html

应该会告诉你应该如何使用这个方法!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53607905

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档