Ionic集成ArcGIS JavaScript API.md
1. Ionic同原生ArcGIS JavaScript API结合
1.1. 安装esri-loader
在工程目录下命令行安装:
npm install angular2-esri-loader esri-loader;
1.2. 构造地图Component
将map.rar这个Component解压到pages文件夹下
这是一个实现参考,定义了一个地图展示Component。
ts代码:
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { EsriLoaderService } from 'angular2-esri-loader';
@Component({
selector: 'app-esri-map',
templateUrl: './esri-map.component.html'
})
export class EsriMapComponent implements OnInit {
map: any;
agoLayer: any;
constructor(private esriLoader: EsriLoaderService) { }
ngOnInit() {
// only load the ArcGIS API for JavaScript when this component is loaded
return this.esriLoader.load({
// use a specific version of the API instead of the latest
url: 'http://10.10.70.85:6090/arcgis_js_api/library/3.20/3.20/init.js'
}).then(() => {
// load the map class needed to create a new map
this.esriLoader.loadModules(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer"]).then(([Map, ArcGISTiledMapServiceLayer]) => {
// create the map at the DOM element in this component
this.map = new Map("mapDiv");
let agoServiceURL = "http://10.10.70.176:6080/arcgis/rest/services/clzhgwnew/cldx/MapServer";
this.agoLayer = new ArcGISTiledMapServiceLayer(agoServiceURL);
this.map.addLayer(this.agoLayer);
});
});
}
}
template代码:
<div id="mapDiv"></div>
1.3. 在app.module.ts中增加引用
import { EsriLoaderService } from 'angular2-esri-loader';
import { EsriMapComponent } from '../pages/map/esri-map.component';
@NgModule({
declarations: [
...
EsriMapComponent,
...
],
imports: [
...
],
bootstrap: [IonicApp],
entryComponents: [
...
EsriMapComponent,
...
],
providers: [
...
EsriLoaderService,
...
]
})
export class AppModule { }
1.4. 增加相关的CSS引用
在index.html中增加如下CSS的引用:
<link rel="stylesheet" href="http://10.10.70.85:6090/arcgis_js_api/library/3.20/3.20/esri/css/esri.css" />
1.5. 地图Component测试
随便找个页面增加如下标签即可显示地图:
...
<app-esri-map></app-esri-map>
...
2. 同自己封装的Dojo组件集成
这里的主要问题是Dojo的组件是基于AMD的模块加载机制进行编写和加载的,主要解决的是Dojo的模块发现和加载。
需要基于第1节中的描述,增加如下配置:
2.1 模块发现
模块发现,还是借助于Dojo的dojoConifg配置项,在index.html的<head>中增加配置项的内容:
<script>
var dojoConfig = {
parseOnLoad:false,
packages: [
{
"name": "must",
"location": "/assets/gis/must"
},
{
"name": "modules",
"location": "/assets/gis/modules"
}
]
};
</script>
这样需要将自己定义的Dojo组件拷贝到src/assets/下的gis`目录下(手工新建目录即可),实现自动同步。
2.1 组件加载
然后就借助于1.2节中的描述,使用esriLoader进行组件加载即可,代码示例如下:
ngOnInit() {
// only load the ArcGIS API for JavaScript when this component is loaded
return this.esriLoader.load({
// use a specific version of the API instead of the latest
url: 'http://10.10.70.85:6090/arcgis_js_api/library/3.20/3.20/init.js'
}).then(() => {
// load the map class needed to create a new map
this.esriLoader.loadModules(["esri/map",
"must/LoadMap",
"esri/geometry/Point",
"must/Toolbar",
"must/mapHandle/MapHandle"]).then(([Map, LoadMap, Point, Toolbar, MapHandle]) => {
//创建右侧工具栏
var mapTool = new MapHandle();
this.gis.loadMap = new LoadMap("mapDiv", mapTool);
var map = this.gis.loadMap.getMap();
this.gis.toolbar = new Toolbar(map);
map.on('load', function () {
});
});
});
}
Ionic集成ArcGIS JavaScript API.md的更多相关文章
- Ionic2集成ArcGIS JavaScript API.md
1. Ionic同原生ArcGIS JavaScript API结合 1.1. 安装esri-loader 在工程目录下命令行安装: npm install angular2-esri-loader ...
- 使用ArcGIS JavaScript API 3.18 加载天地图
对于中国开发者在创建GIS应用的时候,往往比较头疼的是底图资源的缺乏.其实国家测绘地信局就提供一个很好的免费资源:天地图.使用ArcGIS API的开发人员可以直接利用该资源作为地图应用的底图. Ar ...
- 如何正确响应ArcGIS JavaScript API中图形的鼠标事件
在使用ArcGIS JavaScript API编写程序的时候,程序员往往需要完成这样一个功能:点击地图上的图形,自动进行专题GIS数据查询,当在地图非图形区域上点击时,自动进行底图兴趣点查询. 由于 ...
- ArcGIS JavaScript API本地部署离线开发环境[转]
原文地址:http://www.cnblogs.com/brawei/archive/2012/12/28/2837660.html 1 获取ArcGIS JavaScript API API的下载地 ...
- ArcGIS JavaScript API 4.x中热度图渲染的使用注意事项
要使用ArcGIS JavaScript API 4.x的热度图渲染器来渲染要素图层,需要注意几点前提条件: 1.需要使用ArcGIS Server 10.6.1或更高版本发布GIS服务. 2.只支持 ...
- Arcgis Javascript API 开发笔记
JS API3.4的要求 à(1) IE9或以上版本 否则dijit1.8.3不匹配 1.如何发布ArcgisJavascript API应用 0.准备工作: (1).有web应用: (2).有js ...
- ArcGIS Javascript API 加载高德在线地图扩展
利用ArcGIS JavaScript API加载高德在线地图的扩展 /** * Created by WanderGIS on 2015/7/15. */ define(["dojo/_b ...
- Arcgis javascript api 动态图层自图层可见性设置
Arcgis javascript api 动态图层自图层可见性设置 子图层管理 rest服务 sublayers sublayer ArcGISDynamicMapServiceLayer 本文主要 ...
- ArcGIS JavaScript API with jQuery: Error: multipleDefine
I would like to use ArcGIS JavaScript API 4.3 with jQuery, but I am getting following errors. I sea ...
随机推荐
- Zabbix3.0部署最佳实践
Zabbix3整个web界面做了一个全新的设计. 更多新特性请点击当前字幕查看 笔者QQ:572891887 Linux架构交流群:471443208 1.1Zabbix环境准备 [root@li ...
- 异步编程的两种模型,闭包回调,和Lua的coroutine,到底哪一种消耗更大
今天和人讨论了一下CPS变形为闭包回调(典型为C#和JS),以及Lua这种具有真正堆栈,可以yield和resume的coroutine,两种以同步的形式写异步处理逻辑的解决方案的优缺点.之后生出疑问 ...
- Android中的java层的线程暂停和恢复实现
/** * 基础线程对象. * * @author jevan * @version (1.0 at 2013-6-17) * @version (1.1 at 2013-7-2) 增加on ...
- MySQL学习笔记(三)—索引
一.概述 1.基本概念 在大型数据库中,一张表中要容纳几万.几十万,甚至几百万的的数据,而当这些表与其他表连接后,所得到的新的数据数目更是要大大超出原来的表.当用户检索这么大量的数据时,经 ...
- JDBC基础学习(五)—批处理插入数据
一.批处理介绍 当需要成批插入或者更新记录时.可以采用Java的批量更新机制,这一机制允许多条语句一次性提交给数据库批量处理.通常情况下比单独提交处理更有效率. JDBC的批量处理语句包括下 ...
- 【 js 基础 】 深浅拷贝
underscore的源码中,有很多地方用到了 Array.prototype.slice() 方法,但是并没有传参,实际上只是为了返回数组的副本,例如 underscore 中 clone 的方法: ...
- python str.format()
python中的字符串格式函数str.format(): #使用str.format()函数 #使用'{}'占位符 print('I\'m {},{}'.format('Hongten','Welco ...
- 秒懂JS对象、构造器函数和原型对象之间的关系
学习JS的过程中,想要掌握面向对象的程序设计风格,对象模型(原型和继承)是其中的重点和难点,拜读了各类经典书籍和各位前辈的技术文章,感觉都太过高深,花费了不少时间才搞明白(个人智商是硬伤/(ㄒoㄒ)/ ...
- JQ实现选中以后就左右移动
<head> <meta charset="utf-8" /> <title>select_option移动</title> < ...
- html运用以及工具
对于这个教程,我建议你只使用最简单的工具.例如:Notepad(在windows里),TextEdit(在Mac上)或是KEdit(在KDE里)就可以了.一旦你了解这个原理,你就会想要切换到更高级的工 ...