ArcGIS,使用 ArcGIS API 将地图移动到点 JavaScript
ArcGIS, move map to point using ArcGIS API for JavaScript
我是 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
是否不正确):
编辑:我的解决方案,与答案相同。这还不是全部,这是我的应用程序演示 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);
});
您可能没有在文件顶部的 AMD 包含中包含 Point 模块。您的列表应包括 esri/geometry/Point
,如下所示:
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/geometry/Point",
], function(Map, FeatureLayer, Point) {
[... the rest of your code ...]
});
我是 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
是否不正确):
编辑:我的解决方案,与答案相同。这还不是全部,这是我的应用程序演示 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);
});
您可能没有在文件顶部的 AMD 包含中包含 Point 模块。您的列表应包括 esri/geometry/Point
,如下所示:
require([
"esri/map",
"esri/layers/FeatureLayer",
"esri/geometry/Point",
], function(Map, FeatureLayer, Point) {
[... the rest of your code ...]
});