ArcGIS,使用ArcGIS API for JavaScript

时间:2019-05-28 21:45:38

标签: arcgis-js-api

我是ArcGis的新手(也是Angular,我今天将同时在这两者中进行开​​发),找不到关于如何将地图移动到特定点的示例,我正在尝试:

this.mapa.map.centerAt(new Point(-118.15, 33.80));

但是我遇到了JavaScript错误TocComponent.html:10 ERROR ReferenceError: Point is not defined

当我做console.log(this.mapa.map);时,我得到了这个(如果有人怀疑this.mapa.map是否不正确,我会这么做:

enter image description here

编辑:我的解决方案与答案相同。不仅如此,这是我使用Angular进行的应用程序演示:

import { MapaComponent } from '../mapa/mapa.component';

// some code

export class MyComponent implements OnInit {

    constructor(private arcgisService: ArcgisApiService, private mapa: MapaComponent) { }

    // another code

    onChangeSomething(evt: any): void {
        // more code
        loadModules([
            'esri/geometry/Point'
        ]).then(([Point]) => {
            const my_center = new Point([-99.94867549215655, 20.55088183550196]);
            this.mapa.map.centerAndZoom(my_center, 5);
        });

1 个答案:

答案 0 :(得分:1)

您可能未在文件顶部的AMD include中包含Point模块。您的列表应包括esri/geometry/Point,如下所示:

require([
  "esri/map", 
  "esri/layers/FeatureLayer",
  "esri/geometry/Point",
], function(Map, FeatureLayer, Point) {

    [... the rest of your code ...]

});