├── add-baidulayer-4.X ├── readme.md ├── baidumap.png ├── BaiduLayer.html ├── BaiduLayer4.2.html └── js │ └── bism │ └── BaiduLayer.js ├── shp-add-map ├── vendor │ ├── terraformer-arcgis-parser │ │ ├── .npmingnore │ │ ├── .gitignore │ │ ├── .bower.json │ │ ├── terraformer-arcgis-parser.min.js │ │ └── terraformer-arcgis-parser.js │ └── terraformer │ │ ├── .npmignore │ │ ├── .travis.yml │ │ ├── .bower.json │ │ ├── .gitignore │ │ └── terraformer.min.js ├── demo │ ├── index.png │ ├── Big5_case.png │ ├── 10tnvillage.zip │ ├── Shift_JIS_case.png │ ├── themes │ │ ├── basic │ │ │ └── assets │ │ │ │ └── fonts │ │ │ │ ├── icons.eot │ │ │ │ ├── icons.ttf │ │ │ │ └── icons.woff │ │ └── default │ │ │ └── assets │ │ │ ├── fonts │ │ │ ├── icons.eot │ │ │ ├── icons.otf │ │ │ ├── icons.ttf │ │ │ ├── icons.woff │ │ │ └── icons.woff2 │ │ │ └── images │ │ │ └── flags.png │ └── demo.css ├── readme.md ├── lib │ ├── jszip-utils-ie.js │ └── jszip-utils.js ├── preview.js ├── index.html ├── preprocess.js └── src │ └── geojsonlayer.js ├── tianditu4.X ├── tianditu4490.png ├── tiandituMercator.png ├── tiandituMercator.html └── tianditu4490.html ├── basemap-gallery ├── add-basemap.png └── basemap-gallery.html ├── Unique-two-fields ├── two_fields.png └── featurelayer.html ├── slider-Tooltip ├── slider-tooltip.png └── slider-tooltip.html ├── feature-click ├── featurelayer-click.png └── featurelayer-click.html ├── infowindow-move ├── infowindow-move.gif ├── myModules │ ├── InfoWindow.css │ └── InfoWindow.js └── index.html ├── README.md ├── 学习测试的 └── widget学习 │ ├── app │ ├── main.js.map │ ├── main.ts │ ├── main.js │ ├── HelloWorld.js.map │ ├── HelloWorld.tsx │ ├── Rencenter.js.map │ ├── Rencenter.tsx │ ├── HelloWorld.js │ └── Rencenter.js │ ├── package.json │ ├── tsconfig.json │ ├── index.html │ ├── package-lock.json │ ├── HelloWorld.html │ ├── recenter.html │ └── neterwork.html ├── wander ├── wander.min.js ├── wander使用教程.md └── viewgoto.html ├── xiangsu.py ├── 黑科技修改Feature的svg渲染 └── svg.html ├── GP └── clip-GP.html └── Dialog └── dialog.html /add-baidulayer-4.X/readme.md: -------------------------------------------------------------------------------- 1 | ### 该扩展仍存在问题,选择性使用。 2 | -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer-arcgis-parser/.npmingnore: -------------------------------------------------------------------------------- 1 | versions -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer/.npmignore: -------------------------------------------------------------------------------- 1 | examples 2 | versions 3 | source 4 | out 5 | docs -------------------------------------------------------------------------------- /shp-add-map/demo/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/index.png -------------------------------------------------------------------------------- /shp-add-map/readme.md: -------------------------------------------------------------------------------- 1 | ## shp add to arcgis map 2 | 3 | #### 由@dans 提供,改编自 http://gipong.github.io/shp2geojson.js/ -------------------------------------------------------------------------------- /tianditu4.X/tianditu4490.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/tianditu4.X/tianditu4490.png -------------------------------------------------------------------------------- /add-baidulayer-4.X/baidumap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/add-baidulayer-4.X/baidumap.png -------------------------------------------------------------------------------- /basemap-gallery/add-basemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/basemap-gallery/add-basemap.png -------------------------------------------------------------------------------- /shp-add-map/demo/Big5_case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/Big5_case.png -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.11" 4 | - "0.10" 5 | - "0.8" -------------------------------------------------------------------------------- /Unique-two-fields/two_fields.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/Unique-two-fields/two_fields.png -------------------------------------------------------------------------------- /shp-add-map/demo/10tnvillage.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/10tnvillage.zip -------------------------------------------------------------------------------- /slider-Tooltip/slider-tooltip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/slider-Tooltip/slider-tooltip.png -------------------------------------------------------------------------------- /tianditu4.X/tiandituMercator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/tianditu4.X/tiandituMercator.png -------------------------------------------------------------------------------- /feature-click/featurelayer-click.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/feature-click/featurelayer-click.png -------------------------------------------------------------------------------- /infowindow-move/infowindow-move.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/infowindow-move/infowindow-move.gif -------------------------------------------------------------------------------- /shp-add-map/demo/Shift_JIS_case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/Shift_JIS_case.png -------------------------------------------------------------------------------- /shp-add-map/demo/themes/basic/assets/fonts/icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/basic/assets/fonts/icons.eot -------------------------------------------------------------------------------- /shp-add-map/demo/themes/basic/assets/fonts/icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/basic/assets/fonts/icons.ttf -------------------------------------------------------------------------------- /shp-add-map/demo/themes/basic/assets/fonts/icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/basic/assets/fonts/icons.woff -------------------------------------------------------------------------------- /shp-add-map/demo/themes/default/assets/fonts/icons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/default/assets/fonts/icons.eot -------------------------------------------------------------------------------- /shp-add-map/demo/themes/default/assets/fonts/icons.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/default/assets/fonts/icons.otf -------------------------------------------------------------------------------- /shp-add-map/demo/themes/default/assets/fonts/icons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/default/assets/fonts/icons.ttf -------------------------------------------------------------------------------- /shp-add-map/demo/themes/default/assets/fonts/icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/default/assets/fonts/icons.woff -------------------------------------------------------------------------------- /shp-add-map/demo/themes/default/assets/fonts/icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/default/assets/fonts/icons.woff2 -------------------------------------------------------------------------------- /shp-add-map/demo/themes/default/assets/images/flags.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swaggyPYang/esridemo/HEAD/shp-add-map/demo/themes/default/assets/images/flags.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ArcGIS API for JavaScript Demo 2 | esridemo 3 | ArcGIS API for JavaScript Demo,以文件名分类,内含代码及运行效果的图片 4 | 5 | #### 在这里欢迎各位有志之士加入esridemo库的搭建,文件构造规则也需要按照上边的格式就好了,当然如果大家有好的需求或者代码也可以直接发到我的邮箱1547094768@qq.com或者直接提交Issues,相信更好的共享可以方便更多的人。 6 | 7 | ### 愿大家做一个自由的人,让我们一起高呼:We love GFW!!!让我们一起祈祷硬盘坚强!!! 8 | -------------------------------------------------------------------------------- /学习测试的/widget学习/app/main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"main.js","sourceRoot":"","sources":["main.ts"],"names":[],"mappings":";;;IAKA,IAAM,GAAG,GAAG,IAAI,OAAO,CAAC;QACtB,OAAO,EAAE,SAA2B;KACrC,CAAC,CAAC;IAEH,IAAM,IAAI,GAAG,IAAI,OAAO,CAAC;QACvB,GAAG,EAAE,GAAG;QACR,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,IAAI,KAAK,CAAC;YAChB,CAAC,EAAE,OAAO;YACV,CAAC,EAAE,MAAM;SACV,CAAC;QACF,IAAI,EAAE,EAAE;KACT,CAAC,CAAC"} -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer-arcgis-parser/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore complexity output 2 | complexity.xml 3 | 4 | # Ignore Coverage output 5 | coverage 6 | 7 | # Ignore Grunt temp files 8 | .grunt 9 | 10 | # Mac 11 | .DS_Store 12 | Icon 13 | ._* 14 | .Spotlight-V100 15 | # SublimeText 16 | /*.sublime-project 17 | *.sublime-workspace 18 | 19 | #Node 20 | node_modules 21 | npm-debug.log -------------------------------------------------------------------------------- /学习测试的/widget学习/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root-folder", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@types/arcgis-js-api": "^4.7.0" 14 | }, 15 | "devDependencies": { 16 | "dojo-typings": "^1.11.9" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /学习测试的/widget学习/app/main.ts: -------------------------------------------------------------------------------- 1 | import EsriMap = require("esri/Map"); 2 | import MapView = require("esri/views/MapView"); 3 | import Basemap = require("esri/Basemap"); 4 | import Point = require("esri/geometry/Point"); 5 | 6 | const map = new EsriMap({ 7 | basemap: "streets" as any as Basemap 8 | }); 9 | 10 | const view = new MapView({ 11 | map: map, 12 | container: "viewDiv", 13 | center: new Point({ 14 | x: 116.244, 15 | y: 34.052 16 | }), 17 | zoom: 12 18 | }); -------------------------------------------------------------------------------- /wander/wander.min.js: -------------------------------------------------------------------------------- 1 | define(["dojo/_base/declare"],function(n){return n(null,{declareClass:"Wander",constructor:function(n){this.vw=n.view,this.line=n.line,this.opt=n.option},do:function(){var t=this;if("polyline"!=this.line.type)alert("请传入线数据!");else{var n=this.line.paths[0],e=function(n,e){return function(){return t.vw.goTo(n,e)}};func_arr=[];for(var r=0;r=170 and data[1]>=170 and data[2]>=70):#RGBA的r值大于170,并且g值大于170,并且b值大于170 18 | img.putpixel((i,j),(234,53,57,255))#则这些像素点的颜色改成大红色 19 | img = img.convert("RGB")#把图片强制转成RGB 20 | img.save("e:/ces1.png")#保存修改像素点后的图片 -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer-arcgis-parser/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "terraformer-arcgis-parser", 3 | "version": "1.0.4", 4 | "main": "terraformer-arcgis-parser.min.js", 5 | "ignore": [ 6 | "versions", 7 | "benchmarks" 8 | ], 9 | "dependencies": { 10 | "terraformer": "~1.0.3" 11 | }, 12 | "homepage": "https://github.com/Esri/terraformer-arcgis-parser", 13 | "_release": "1.0.4", 14 | "_resolution": { 15 | "type": "version", 16 | "tag": "v1.0.4", 17 | "commit": "fb13001a49136be04885ba4805a13fb9afd9629a" 18 | }, 19 | "_source": "git://github.com/Esri/terraformer-arcgis-parser.git", 20 | "_target": "~1.0.4", 21 | "_originalSource": "terraformer-arcgis-parser", 22 | "_direct": true 23 | } -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore complexity output 2 | complexity.xml 3 | 4 | # Ignore Coverage output 5 | .coverage 6 | 7 | # Ignore Grunt temp files 8 | .grunt 9 | 10 | # Ignore environment variables set on this machine 11 | .env 12 | 13 | # Ignore the doc output 14 | docs-build 15 | 16 | # Mac 17 | .DS_Store 18 | Icon 19 | ._* 20 | .Spotlight-V100 21 | # SublimeText 22 | /*.sublime-project 23 | *.sublime-workspace 24 | 25 | # SASS 26 | .sass-cache 27 | 28 | #Node 29 | node_modules 30 | 31 | #anvil 32 | /index.html 33 | 34 | # Ruby 35 | *.gem 36 | *.rbc 37 | .bundle 38 | .config 39 | coverage 40 | InstalledFiles 41 | lib/bundler/man 42 | pkg 43 | rdoc 44 | spec/reports 45 | test/tmp 46 | test/version_tmp 47 | tmp 48 | Gemfile.lock 49 | 50 | # YARD artifacts 51 | .yardoc 52 | _yardoc 53 | doc/ 54 | -------------------------------------------------------------------------------- /学习测试的/widget学习/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "amd",//Will compile TypeScript code to AMD modules as needed by the JavaScript API. 4 | "noImplicitAny": true, 5 | "sourceMap": true, 6 | "jsx": "react", 7 | "jsxFactory": "tsx", 8 | "target": "es5",//Output to ES5 to work across all supported browsers 9 | "experimentalDecorators": true, 10 | "preserveConstEnums": true, 11 | "suppressImplicitAnyIndexErrors": true 12 | }, 13 | "include": [ 14 | "./app/*"//Array of files to compile. Can use glob-like file patterns. 15 | ], 16 | "exclude": [ 17 | "node_modules" 18 | ] 19 | } 20 | //tsc - This command will look at your tsconfig.json file and compile your TypeScript based on its configuration. 21 | //tsc -w - This command does the same as above, but will also watch for file changes and recompile files as you edit them -------------------------------------------------------------------------------- /学习测试的/widget学习/app/HelloWorld.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"HelloWorld.js","sourceRoot":"","sources":["HelloWorld.tsx"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,kFAAkF;;;;;;;;;;;;;;;;;;;IAQlF,IAAM,GAAG,GAAG;QACV,IAAI,EAAE,kBAAkB;QACxB,QAAQ,EAAE,4BAA4B;KACvC,CAAC;IAEF;QAAyB,8BAAgB;QADzC;YAAA,qEA+CC;YA7CA;;cAEE;YAGF,eAAS,GAAS,MAAM,CAAC;YAEzB;;cAEE;YAGF,cAAQ,GAAS,MAAM,CAAC;YAExB;;cAEE;YAIF,gBAAU,GAAY,KAAK,CAAC;;QAyB7B,CAAC;QAvBA;;UAEE;QACF,2BAAM,GAAN;YACG,IAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;YACrC,IAAM,OAAO;gBACX,GAAC,GAAG,CAAC,QAAQ,IAAG,IAAI,CAAC,UAAU;mBAChC,CAAC;YAEF,OAAO,CACL,sBAAK,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,IACxC,QAAQ,CACL,CACL,CAAC;;QACL,CAAC;QAED;;UAEA;QACM,iCAAY,GAApB;YACG,OAAO,uBAAqB,IAAI,CAAC,SAAS,SAAI,IAAI,CAAC,QAAQ,MAAG,CAAC;QACjE,CAAC;QAtCF;YAFC,qBAAQ,EAAE;YACV,mBAAU,EAAE;qDACY;QAOzB;YAFC,qBAAQ,EAAE;YACV,mBAAU,EAAE;oDACW;QAQxB;YAFC,qBAAQ,EAAE;YACV,mBAAU,EAAE;sDACe;QArBvB,UAAU;YADf,qBAAQ,CAAC,yBAAyB,CAAC;WAC9B,UAAU,CA8Cf;QAAD,iBAAC;KAAA,AA9CD,CAAyB,qBAAQ,CAAC,MAAM,CAAC,GA8CxC;IAED,OAAS,UAAU,CAAC"} -------------------------------------------------------------------------------- /学习测试的/widget学习/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ArcGIS JSAPI 4.7 TypeScript Demo 7 | 17 | 18 | 29 | 30 | 31 | 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /学习测试的/widget学习/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "root-folder", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/arcgis-js-api": { 8 | "version": "4.7.0", 9 | "resolved": "https://registry.npmjs.org/@types/arcgis-js-api/-/arcgis-js-api-4.7.0.tgz", 10 | "integrity": "sha512-wnIC+c0T6W8anZnSCzu+NRAvPiaJGSdrG3jCukbkb99UY2HKCiXmBsarQQApBV32yyPRHmLPXWNVH3l2xcF64Q==" 11 | }, 12 | "@types/chai": { 13 | "version": "4.1.3", 14 | "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.3.tgz", 15 | "integrity": "sha512-f5dXGzOJycyzSMdaXVhiBhauL4dYydXwVpavfQ1mVCaGjR56a9QfklXObUxlIY9bGTmCPHEEZ04I16BZ/8w5ww==", 16 | "dev": true 17 | }, 18 | "dojo-typings": { 19 | "version": "1.11.9", 20 | "resolved": "https://registry.npmjs.org/dojo-typings/-/dojo-typings-1.11.9.tgz", 21 | "integrity": "sha512-mh8w+Mau2Y1QfTEszEAdO7j6ycNhYxF/Ing6nAk1eUg6NxjeT0viVHjICMd9sU3U463vM2G+KfBBK5grk3/Mlw==", 22 | "dev": true, 23 | "requires": { 24 | "@types/chai": "4.1.3" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /slider-Tooltip/slider-tooltip.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | FeatureLayer 7 | 8 | 9 | 10 | 11 | 19 | 20 | 49 | 50 | 51 | 52 |
53 | 54 | 55 | -------------------------------------------------------------------------------- /infowindow-move/myModules/InfoWindow.css: -------------------------------------------------------------------------------- 1 | 2 | 3 | .myInfoWindow 4 | { 5 | position: absolute; 6 | z-index: 100; 7 | width: 301px; 8 | height: 301px; 9 | border-radius: 5px; 10 | -moz-border-radius: 5px; 11 | -webkit-border-radius: 5px; 12 | -o-border-radius: 5px; 13 | -moz-box-shadow: 0 0 1em #26393D; 14 | border: 2px solid #046380; 15 | font-family: sans-serif; 16 | font-size: 12px; 17 | background-color:#EFECCA; 18 | 19 | } 20 | 21 | /*关闭按钮*/ 22 | .myInfoWindow .close 23 | { 24 | position: absolute; top: 0px; right: 0px; 25 | cursor: pointer; 26 | background: url(https://serverapi.arcgisonline.com/jsapi/arcgis/2.6/js/dojo/dijit/themes/claro/layout/images/tabClose.png) no-repeat scroll 0 0 transparent; 27 | width: 12px; height: 12px; 28 | margin: 3px 3px 0px 0px; 29 | z-index: 8000; 30 | } 31 | 32 | .myInfoWindow .close:hover 33 | { 34 | background-color: #F7FCFF; 35 | } 36 | 37 | /*弹窗标题*/ 38 | .myInfoWindow .title 39 | { 40 | cursor: move; 41 | font-weight: bold; 42 | padding: 2px 2px 2px 2px; 43 | background-color:#1e4862; 44 | opacity: 0.4; 45 | color:#E6E2AF; 46 | height: 20px; 47 | } 48 | -------------------------------------------------------------------------------- /学习测试的/widget学习/app/HelloWorld.tsx: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | import {subclass, declared, property} from "esri/core/accessorSupport/decorators"; 5 | 6 | import Widget = require("esri/widgets/Widget"); 7 | 8 | import { renderable, tsx } from "esri/widgets/support/widget"; 9 | 10 | const CSS = { 11 | base: "esri-hello-world", 12 | emphasis: "esri-hello-world--emphasis" 13 | }; 14 | @subclass("esri.widgets.HelloWorld") 15 | class HelloWorld extends declared(Widget){ 16 | /* 17 | **firstName 18 | */ 19 | @property() 20 | @renderable() 21 | firstName:string ="Nike"; 22 | 23 | /* 24 | **lastName 25 | */ 26 | @property() 27 | @renderable() 28 | lastName:string ="Yang"; 29 | 30 | /* 31 | **emphasized 32 | */ 33 | 34 | @property() 35 | @renderable() 36 | emphasized: boolean = false; 37 | 38 | /* 39 | **Public Methods 40 | */ 41 | render() { 42 | const greeting = this._getGreeting(); 43 | const classes = { 44 | [CSS.emphasis]: this.emphasized 45 | }; 46 | 47 | return ( 48 |
49 | {greeting} 50 |
51 | ); 52 | } 53 | 54 | /* 55 | **Private Methods 56 | */ 57 | private _getGreeting(): string { 58 | return `Hello, my name is ${this.firstName} ${this.lastName}!`; 59 | } 60 | 61 | } 62 | 63 | export = HelloWorld; -------------------------------------------------------------------------------- /add-baidulayer-4.X/BaiduLayer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 访问百度地图 6 | 7 | 15 | 24 | 25 | 26 | 27 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /学习测试的/widget学习/app/Rencenter.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Rencenter.js","sourceRoot":"","sources":["Rencenter.tsx"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,kFAAkF;;;;;;;;;;;;;;;;;;;IA2BlF,IAAM,GAAG,GAAG;QACV,IAAI,EAAE,eAAe;KACtB,CAAC;IAGF;QAAuB,4BAAgB;QAErC;YAAA,YACE,iBAAO,SAER;YADC,KAAI,CAAC,aAAa,GAAG,KAAI,CAAC,aAAa,CAAC,IAAI,CAAC,KAAI,CAAC,CAAA;;QACpD,CAAC;QAED,iCAAc,GAAd;YAAA,iBAGC;YAFC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,2CAA2C,EAAE,cAAM,OAAA,KAAI,CAAC,aAAa,EAAE,EAApB,CAAoB,CAAC,CAAC;QAEjG,CAAC;QAgCD,qEAAqE;QACrE,EAAE;QACF,kBAAkB;QAClB,EAAE;QACF,qEAAqE;QAErE,yBAAM,GAAN;YACQ,IAAA,eAA4B,EAA1B,QAAC,EAAE,QAAC,EAAE,gBAAK,CAAgB;YACnC,IAAM,MAAM,GAAU;gBACpB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,EAAE;aACzF,CAAC;YACF,OAAO,CACL,sBACE,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,GAAG,CAAC,IAAI,EACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,IAAI,CAAC,cAAc;gBAC5B;;oBAAO,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAK;gBAChC;;oBAAO,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAK;gBAChC;;oBAAW,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAK,CACpC,CACP,CAAC;QACJ,CAAC;QAED,qEAAqE;QACrE,EAAE;QACF,mBAAmB;QACnB,EAAE;QACF,qEAAqE;QAE7D,gCAAa,GAArB;YACM,IAAA,cAA0C,EAAxC,4BAAW,EAAE,kBAAM,EAAE,gBAAK,CAAe;YAC/C,IAAI,CAAC,KAAK,GAAG;gBACX,CAAC,EAAE,MAAM,CAAC,CAAC;gBACX,CAAC,EAAE,MAAM,CAAC,CAAC;gBACX,WAAW,aAAA;gBACX,KAAK,OAAA;aACN,CAAC;QACJ,CAAC;QAEO,iCAAc,GAAtB;YACE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;QA5DD;YAFC,qBAAQ,EAAE;YACV,mBAAU,EAAE;8CACC;QAQd;YAFC,qBAAQ,EAAE;YACV,mBAAU,EAAE;uDACc;QAQ3B;YAFC,qBAAQ,EAAE;YACV,mBAAU,EAAE;+CACA;QAxCT,QAAQ;YADb,qBAAQ,CAAC,uBAAuB,CAAC;WAC5B,QAAQ,CAqFb;QAAD,eAAC;KAAA,AArFD,CAAuB,qBAAQ,CAAC,MAAM,CAAC,GAqFtC;IAED,OAAS,QAAQ,CAAC"} -------------------------------------------------------------------------------- /add-baidulayer-4.X/BaiduLayer4.2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 访问百度地图 6 | 7 | 15 | 24 | 25 | 26 | 27 | 52 | 53 | 54 |
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /feature-click/featurelayer-click.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Feature Layer Only Map 7 | 8 | 16 | 17 | 58 | 59 | 60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /学习测试的/widget学习/HelloWorld.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Create a custom widget - 4.7 8 | 9 | 19 | 30 | 31 | 73 | 74 | 75 | 76 |
77 | 78 | -------------------------------------------------------------------------------- /学习测试的/widget学习/recenter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Custom Recenter Widget - 4.7 8 | 9 | 10 | 37 | 48 | 49 | 82 | 83 | 84 |
85 | 86 | -------------------------------------------------------------------------------- /黑科技修改Feature的svg渲染/svg.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | FeatureLayer 7 | 8 | 9 | 10 | 11 | 19 | 20 | 67 | 68 | 69 | 70 |
71 | 72 | 73 | -------------------------------------------------------------------------------- /shp-add-map/lib/jszip-utils-ie.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\r\n"+ 18 | "\r\n"; 32 | 33 | // inject VBScript 34 | document.write(IEBinaryToArray_ByteStr_Script); 35 | 36 | global.JSZipUtils._getBinaryFromXHR = function (xhr) { 37 | var binary = xhr.responseBody; 38 | var byteMapping = {}; 39 | for ( var i = 0; i < 256; i++ ) { 40 | for ( var j = 0; j < 256; j++ ) { 41 | byteMapping[ String.fromCharCode( i + (j << 8) ) ] = 42 | String.fromCharCode(i) + String.fromCharCode(j); 43 | } 44 | } 45 | var rawBytes = IEBinaryToArray_ByteStr(binary); 46 | var lastChr = IEBinaryToArray_ByteStr_Last(binary); 47 | return rawBytes.replace(/[\s\S]/g, function( match ) { 48 | return byteMapping[match]; 49 | }) + lastChr; 50 | }; 51 | 52 | // enforcing Stuk's coding style 53 | // vim: set shiftwidth=4 softtabstop=4: 54 | 55 | },{}]},{},[1]) 56 | ; -------------------------------------------------------------------------------- /GP/clip-GP.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 13 | 14 | 15 | 93 | 94 |
95 | 96 | 97 | -------------------------------------------------------------------------------- /Unique-two-fields/featurelayer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Unique Value Renderer 8 | 9 | 16 | 17 | 64 | 65 | 66 | 67 |
68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /tianditu4.X/tiandituMercator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Load a basic WebMap - 4.5 8 | 9 | 19 | 20 | 21 | 22 | 23 | 85 | 86 | 87 | 88 |
89 | 90 | 91 | -------------------------------------------------------------------------------- /basemap-gallery/basemap-gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Basemap gallery 8 | 9 | 10 | 16 | 17 | 18 | 60 | 61 | 62 | 63 |
66 | 67 |
71 | 72 |
73 |
75 |
76 |
77 |
78 |
79 |
80 | 81 |
82 |
83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /wander/viewgoto.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Intro to SceneLayer - 4.8 7 | 17 | 18 | 19 | 20 | 21 | 114 | 115 | 116 | 117 |
118 | 119 | -------------------------------------------------------------------------------- /学习测试的/widget学习/app/Rencenter.tsx: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | import { subclass, declared, property } from "esri/core/accessorSupport/decorators"; 5 | import Widget = require("esri/widgets/Widget"); 6 | import watchUtils = require("esri/core/watchUtils"); 7 | 8 | import { renderable, tsx } from "esri/widgets/support/widget"; 9 | 10 | import Point = require("esri/geometry/Point"); 11 | import MapView = require("esri/views/MapView"); 12 | 13 | type Coordinates = Point | number[] | any; 14 | 15 | interface Center { 16 | x: number; 17 | y: number; 18 | } 19 | 20 | interface State extends Center { 21 | interacting: boolean; 22 | scale: number; 23 | } 24 | 25 | interface Style { 26 | textShadow: string; 27 | } 28 | 29 | const CSS = { 30 | base: "recenter-tool" 31 | }; 32 | 33 | @subclass("esri.widgets.Recenter") 34 | class Recenter extends declared(Widget) { 35 | 36 | constructor() { 37 | super(); 38 | this._onViewChange = this._onViewChange.bind(this) 39 | } 40 | 41 | postInitialize() { 42 | watchUtils.init(this, "view.center, view.interacting, view.scale", () => this._onViewChange()); 43 | 44 | } 45 | 46 | //-------------------------------------------------------------------- 47 | // 48 | // Properties 49 | // 50 | //-------------------------------------------------------------------- 51 | 52 | //---------------------------------- 53 | // view 54 | //---------------------------------- 55 | 56 | @property() 57 | @renderable() 58 | view: MapView; 59 | 60 | //---------------------------------- 61 | // initialCenter 62 | //---------------------------------- 63 | 64 | @property() 65 | @renderable() 66 | initialCenter: Coordinates; 67 | 68 | //---------------------------------- 69 | // state 70 | //---------------------------------- 71 | 72 | @property() 73 | @renderable() 74 | state: State; 75 | 76 | //------------------------------------------------------------------- 77 | // 78 | // Public methods 79 | // 80 | //------------------------------------------------------------------- 81 | 82 | render() { 83 | const { x, y, scale } = this.state; 84 | const styles: Style = { 85 | textShadow: this.state.interacting ? '-1px 0 red, 0 1px red, 1px 0 red, 0 -1px red' : '' 86 | }; 87 | return ( 88 |
93 |

x: {Number(x).toFixed(3)}

94 |

y: {Number(y).toFixed(3)}

95 |

scale: {Number(scale).toFixed(5)}

96 |
97 | ); 98 | } 99 | 100 | //------------------------------------------------------------------- 101 | // 102 | // Private methods 103 | // 104 | //------------------------------------------------------------------- 105 | 106 | private _onViewChange() { 107 | let { interacting, center, scale } = this.view; 108 | this.state = { 109 | x: center.x, 110 | y: center.y, 111 | interacting, 112 | scale 113 | }; 114 | } 115 | 116 | private _defaultCenter() { 117 | this.view.goTo(this.initialCenter); 118 | } 119 | } 120 | 121 | export = Recenter; -------------------------------------------------------------------------------- /infowindow-move/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 14 | 22 | 23 | 99 | 100 | 101 |
102 | 103 | 104 | -------------------------------------------------------------------------------- /shp-add-map/demo/demo.css: -------------------------------------------------------------------------------- 1 | .upload { 2 | position: relative; 3 | overflow: hidden; 4 | } 5 | .upload input[type=file] { 6 | position: absolute; 7 | top: 0; 8 | right: 0; 9 | min-width: 100%; 10 | min-height: 100%; 11 | font-size: 100px; 12 | text-align: right; 13 | filter: alpha(opacity=0); 14 | opacity: 0; 15 | outline: none; 16 | background: white; 17 | cursor: inherit; 18 | display: block; 19 | } 20 | .tableDisplay { 21 | height: auto; 22 | max-height: 400px; 23 | overflow: auto; 24 | } 25 | .picInfo { 26 | transform: scale(0, 0); 27 | transition: transform 0.6s ease; 28 | } 29 | #dataInfo { 30 | text-align: center; 31 | } 32 | #option, #downloadLink { 33 | display: none; 34 | } 35 | #info { 36 | position: absolute; 37 | width: 100%; 38 | top: 10%; 39 | bottom: 20%; 40 | text-align: center 41 | } 42 | #downloadLink { 43 | position: absolute; 44 | width: 100%; 45 | top: 5%; 46 | margin-left: auto; 47 | margin-right: auto 48 | } 49 | #attr { 50 | position: absolute; 51 | width: 30%; 52 | margin-left: 5%; 53 | top: 10%; 54 | display: none; 55 | } 56 | #cancelAttr { 57 | width: 100%; 58 | } 59 | #footer { 60 | position: absolute; 61 | width: 100%; 62 | top: 86%; 63 | } 64 | #map { 65 | height: 100%; 66 | width: 100%; 67 | position: absolute; 68 | top: 0; 69 | left: 0; 70 | z-index: 0; 71 | } 72 | #forkongithub a { 73 | background:#000; 74 | color:#fff; 75 | text-decoration:none; 76 | font-family:arial,sans-serif; 77 | text-align:center; 78 | font-weight:bold; 79 | padding:5px 40px; 80 | font-size:1rem; 81 | line-height:2rem; 82 | position:relative; 83 | transition:0.5s; 84 | } 85 | #forkongithub a:hover { 86 | background:#c11; 87 | color:#fff; 88 | } 89 | #forkongithub a::before,#forkongithub a::after { 90 | content:""; 91 | width:100%; 92 | display:block; 93 | position:absolute; 94 | top:1px; 95 | left:0; 96 | height:1px; 97 | background:#fff; 98 | } 99 | #forkongithub a::after { 100 | bottom:1px; 101 | top:auto; 102 | } 103 | @media screen { 104 | #forkongithub{ 105 | position:absolute; 106 | display:block; 107 | top:0; 108 | right:0; 109 | width:200px; 110 | overflow:hidden; 111 | height:200px; 112 | z-index:9999; 113 | } 114 | #forkongithub a { 115 | position:absolute; 116 | top:35px; 117 | right:-55px; 118 | transform:rotate(45deg); 119 | -webkit-transform:rotate(45deg); 120 | -ms-transform:rotate(45deg); 121 | -moz-transform:rotate(45deg); 122 | -o-transform:rotate(45deg); 123 | } 124 | } 125 | .shp-modal { 126 | position: fixed; 127 | top: 30%; 128 | left: 22%; 129 | right: 22%; 130 | max-width: 1024px; 131 | height: auto; 132 | z-index: 2000; 133 | visibility: hidden; 134 | transform: scale(0.8); 135 | transition: all 0.09s ease; 136 | } 137 | .overlay { 138 | position: fixed; 139 | width: 100%; 140 | height: 100%; 141 | visibility: hidden; 142 | top: 0; 143 | left: 0; 144 | z-index: 1000; 145 | background: rgba(242, 235, 234, 0.8); 146 | transition: all 0.09s ease; 147 | } 148 | .effect { 149 | transform: scale(1.0); 150 | visibility: visible; 151 | transition: all 0.4s ease; 152 | } 153 | .blur { 154 | -webkit-filter: blur(5px); 155 | -moz-filter: blur(5px); 156 | filter: blur(5px); 157 | } -------------------------------------------------------------------------------- /学习测试的/widget学习/app/HelloWorld.js: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | var __extends = (this && this.__extends) || (function () { 4 | var extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return function (d, b) { 8 | extendStatics(d, b); 9 | function __() { this.constructor = d; } 10 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 11 | }; 12 | })(); 13 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 14 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 15 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 16 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 17 | return c > 3 && r && Object.defineProperty(target, key, r), r; 18 | }; 19 | define(["require", "exports", "esri/core/tsSupport/declareExtendsHelper", "esri/core/tsSupport/decorateHelper", "esri/core/accessorSupport/decorators", "esri/widgets/Widget", "esri/widgets/support/widget"], function (require, exports, __extends, __decorate, decorators_1, Widget, widget_1) { 20 | "use strict"; 21 | var CSS = { 22 | base: "esri-hello-world", 23 | emphasis: "esri-hello-world--emphasis" 24 | }; 25 | var HelloWorld = /** @class */ (function (_super) { 26 | __extends(HelloWorld, _super); 27 | function HelloWorld() { 28 | var _this = _super !== null && _super.apply(this, arguments) || this; 29 | /* 30 | **firstName 31 | */ 32 | _this.firstName = "Nike"; 33 | /* 34 | **lastName 35 | */ 36 | _this.lastName = "Yang"; 37 | /* 38 | **emphasized 39 | */ 40 | _this.emphasized = false; 41 | return _this; 42 | } 43 | /* 44 | **Public Methods 45 | */ 46 | HelloWorld.prototype.render = function () { 47 | var greeting = this._getGreeting(); 48 | var classes = (_a = {}, 49 | _a[CSS.emphasis] = this.emphasized, 50 | _a); 51 | return (widget_1.tsx("div", { class: this.classes(CSS.base, classes) }, greeting)); 52 | var _a; 53 | }; 54 | /* 55 | **Private Methods 56 | */ 57 | HelloWorld.prototype._getGreeting = function () { 58 | return "Hello, my name is " + this.firstName + " " + this.lastName + "!"; 59 | }; 60 | __decorate([ 61 | decorators_1.property(), 62 | widget_1.renderable() 63 | ], HelloWorld.prototype, "firstName", void 0); 64 | __decorate([ 65 | decorators_1.property(), 66 | widget_1.renderable() 67 | ], HelloWorld.prototype, "lastName", void 0); 68 | __decorate([ 69 | decorators_1.property(), 70 | widget_1.renderable() 71 | ], HelloWorld.prototype, "emphasized", void 0); 72 | HelloWorld = __decorate([ 73 | decorators_1.subclass("esri.widgets.HelloWorld") 74 | ], HelloWorld); 75 | return HelloWorld; 76 | }(decorators_1.declared(Widget))); 77 | return HelloWorld; 78 | }); 79 | //# sourceMappingURL=HelloWorld.js.map -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer-arcgis-parser/terraformer-arcgis-parser.min.js: -------------------------------------------------------------------------------- 1 | /*! Terraformer ArcGIS Parser - 1.0.4 - 2014-06-17 2 | * https://github.com/esri/terraformer-arcgis-parser 3 | * Copyright (c) 2014 Esri, Inc. 4 | * Licensed MIT */!function(a,b){if("object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b(require("terraformer"))),"object"==typeof a.navigator){if(!a.Terraformer)throw new Error("Terraformer.ArcGIS requires the core Terraformer library. https://github.com/esri/Terraformer");a.Terraformer.ArcGIS=b(a.Terraformer)}}(this,function(a){function b(a){var b,c,d,e,f=0,g=0,h=[];d=a.match(/((\+|\-)[^\+\-]+)/g),e=parseInt(d[0],32);for(var i=1;id;d++)b=a[d+1],c+=(b[0]-f[0])*(b[1]+f[1]),f=b;return c>=0}function g(a){var b=[],d=a.slice(0),e=c(d.shift().slice(0));if(e.length>=4){f(e)||e.reverse(),b.push(e);for(var g=0;g=4&&(f(h)&&h.reverse(),b.push(h))}}return b}function h(a){for(var b=[],c=0;c=0;e--){var f=d[e].slice(0);b.push(f)}return b}function i(b,c){var d=a.Tools.arraysIntersectArrays(b,c),e=a.Tools.coordinatesContainPoint(b,c[0]);return!d&&e?!0:!1}function j(a){for(var b=[],d=[],e=0;e=0;l--){var m=b[l][0];if(i(m,j)){b[l].push(j),k=!0;break}}k||b.push([j.reverse()])}return 1===b.length?{type:"Polygon",coordinates:b[0]}:{type:"MultiPolygon",coordinates:b}}function k(c,d){var f={};d=d||{},d.idAttribute=d.idAttribute||void 0,"number"==typeof c.x&&"number"==typeof c.y&&(f.type="Point",f.coordinates=[c.x,c.y],(c.z||c.m)&&f.coordinates.push(c.z),c.m&&f.coordinates.push(c.m)),c.points&&(f.type="MultiPoint",f.coordinates=c.points.slice(0)),c.paths&&(1===c.paths.length?(f.type="LineString",f.coordinates=c.paths[0].slice(0)):(f.type="MultiLineString",f.coordinates=c.paths.slice(0))),c.rings&&(f=j(c.rings.slice(0))),(c.compressedGeometry||c.geometry||c.attributes)&&(f.type="Feature",c.compressedGeometry&&(c.geometry={paths:[b(c.compressedGeometry)]}),f.geometry=c.geometry?k(c.geometry):null,f.properties=c.attributes?e(c.attributes):null,c.attributes&&(f.id=c.attributes[d.idAttribute]||c.attributes.OBJECTID||c.attributes.FID));var g=c.geometry?c.geometry.spatialReference:c.spatialReference;return g&&102100===g.wkid&&(f=a.toGeographic(f)),new a.Primitive(f)}function l(b,c){var d;c=c||{};var f=c.idAttribute||"OBJECTID";d=c.sr?{wkid:c.sr}:b&&b.crs===a.MercatorCRS?{wkid:102100}:{wkid:4326};var i,j={};switch(b.type){case"Point":j.x=b.coordinates[0],j.y=b.coordinates[1],b.coordinates[2]&&(j.z=b.coordinates[2]),b.coordinates[3]&&(j.m=b.coordinates[3]),j.spatialReference=d;break;case"MultiPoint":j.points=b.coordinates.slice(0),j.spatialReference=d;break;case"LineString":j.paths=[b.coordinates.slice(0)],j.spatialReference=d;break;case"MultiLineString":j.paths=b.coordinates.slice(0),j.spatialReference=d;break;case"Polygon":j.rings=g(b.coordinates.slice(0)),j.spatialReference=d;break;case"MultiPolygon":j.rings=h(b.coordinates.slice(0)),j.spatialReference=d;break;case"Feature":b.geometry&&(j.geometry=l(b.geometry,c)),j.attributes=b.properties?e(b.properties):{},j.attributes[f]=b.id;break;case"FeatureCollection":for(j=[],i=0;i 2 | /// 3 | var __extends = (this && this.__extends) || (function () { 4 | var extendStatics = Object.setPrototypeOf || 5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 6 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7 | return function (d, b) { 8 | extendStatics(d, b); 9 | function __() { this.constructor = d; } 10 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 11 | }; 12 | })(); 13 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 14 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 15 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 16 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 17 | return c > 3 && r && Object.defineProperty(target, key, r), r; 18 | }; 19 | define(["require", "exports", "esri/core/tsSupport/declareExtendsHelper", "esri/core/tsSupport/decorateHelper", "esri/core/accessorSupport/decorators", "esri/widgets/Widget", "esri/core/watchUtils", "esri/widgets/support/widget"], function (require, exports, __extends, __decorate, decorators_1, Widget, watchUtils, widget_1) { 20 | "use strict"; 21 | var CSS = { 22 | base: "recenter-tool" 23 | }; 24 | var Recenter = /** @class */ (function (_super) { 25 | __extends(Recenter, _super); 26 | function Recenter() { 27 | var _this = _super.call(this) || this; 28 | _this._onViewChange = _this._onViewChange.bind(_this); 29 | return _this; 30 | } 31 | Recenter.prototype.postInitialize = function () { 32 | var _this = this; 33 | watchUtils.init(this, "view.center, view.interacting, view.scale", function () { return _this._onViewChange(); }); 34 | }; 35 | //------------------------------------------------------------------- 36 | // 37 | // Public methods 38 | // 39 | //------------------------------------------------------------------- 40 | Recenter.prototype.render = function () { 41 | var _a = this.state, x = _a.x, y = _a.y, scale = _a.scale; 42 | var styles = { 43 | textShadow: this.state.interacting ? '-1px 0 red, 0 1px red, 1px 0 red, 0 -1px red' : '' 44 | }; 45 | return (widget_1.tsx("div", { bind: this, class: CSS.base, styles: styles, onclick: this._defaultCenter }, 46 | widget_1.tsx("p", null, 47 | "x: ", 48 | Number(x).toFixed(3)), 49 | widget_1.tsx("p", null, 50 | "y: ", 51 | Number(y).toFixed(3)), 52 | widget_1.tsx("p", null, 53 | "scale: ", 54 | Number(scale).toFixed(5)))); 55 | }; 56 | //------------------------------------------------------------------- 57 | // 58 | // Private methods 59 | // 60 | //------------------------------------------------------------------- 61 | Recenter.prototype._onViewChange = function () { 62 | var _a = this.view, interacting = _a.interacting, center = _a.center, scale = _a.scale; 63 | this.state = { 64 | x: center.x, 65 | y: center.y, 66 | interacting: interacting, 67 | scale: scale 68 | }; 69 | }; 70 | Recenter.prototype._defaultCenter = function () { 71 | this.view.goTo(this.initialCenter); 72 | }; 73 | __decorate([ 74 | decorators_1.property(), 75 | widget_1.renderable() 76 | ], Recenter.prototype, "view", void 0); 77 | __decorate([ 78 | decorators_1.property(), 79 | widget_1.renderable() 80 | ], Recenter.prototype, "initialCenter", void 0); 81 | __decorate([ 82 | decorators_1.property(), 83 | widget_1.renderable() 84 | ], Recenter.prototype, "state", void 0); 85 | Recenter = __decorate([ 86 | decorators_1.subclass("esri.widgets.Recenter") 87 | ], Recenter); 88 | return Recenter; 89 | }(decorators_1.declared(Widget))); 90 | return Recenter; 91 | }); 92 | //# sourceMappingURL=Rencenter.js.map -------------------------------------------------------------------------------- /学习测试的/widget学习/neterwork.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Directions Widget 7 | 8 | 9 | 22 | 23 | 24 | 92 | 93 | 94 |
97 |
100 | 101 |
102 |
103 |
106 |
107 |
108 | 109 | 110 | -------------------------------------------------------------------------------- /shp-add-map/lib/jszip-utils.js: -------------------------------------------------------------------------------- 1 | /*! 2 | 3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip. 4 | 5 | 6 | (c) 2014 Stuart Knightley, David Duponchel 7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown. 8 | 9 | */ 10 | !function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.JSZipUtils=e():"undefined"!=typeof global?global.JSZipUtils=e():"undefined"!=typeof self&&(self.JSZipUtils=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 2 | 3 | 4 | 5 | 6 | 7 | Feature Layer - display results as an InfoWindow onClick 8 | 9 | 10 | 11 | 39 | 40 | 41 | 133 | 134 | 135 |
136 |
137 | show samething here 138 |
139 |
140 | click a county in South Carolina to get more information. 141 |
142 |
143 | 144 | 145 | -------------------------------------------------------------------------------- /shp-add-map/preview.js: -------------------------------------------------------------------------------- 1 | /* 2 | * predefined [EPSG:3821] projection 3 | * Please make sure your desired projection can find on http://epsg.io/ 4 | * 5 | * Usage : 6 | * loadshp({ 7 | * url: '/shp/test.zip', // path or your upload file 8 | * encoding: 'big5' // default utf-8 9 | * EPSG: 3826 // default 4326 10 | * }, function(geojson) { 11 | * // geojson returned 12 | * }); 13 | * 14 | * Created by Gipong 15 | * 16 | */ 17 | 18 | var inputData = {}, 19 | geoData = {}, 20 | EPSGUser, url, encoding, EPSG, 21 | EPSG4326 = proj4('EPSG:4326'); 22 | 23 | function loadshp(config, returnData) { 24 | url = config.url; 25 | encoding = typeof config.encoding != 'utf-8' ? config.encoding : 'utf-8'; 26 | EPSG = typeof config.EPSG != 'undefined' ? config.EPSG : 4326; 27 | 28 | loadEPSG('http://epsg.io/'+EPSG+'.js', function() { 29 | if(EPSG == 3821) 30 | proj4.defs([ 31 | ['EPSG:3821', '+proj=tmerc +ellps=GRS67 +towgs84=-752,-358,-179,-.0000011698,.0000018398,.0000009822,.00002329 +lat_0=0 +lon_0=121 +x_0=250000 +y_0=0 +k=0.9999 +units=m +no_defs'] 32 | ]); 33 | 34 | EPSGUser = proj4('EPSG:'+EPSG); 35 | 36 | if(typeof url != 'string') { 37 | var reader = new FileReader(); 38 | reader.onload = function(e) { 39 | var URL = window.URL || window.webkitURL || window.mozURL || window.msURL, 40 | zip = new JSZip(e.target.result), 41 | shpString = zip.file(/.shp$/i)[0].name, 42 | dbfString = zip.file(/.dbf$/i)[0].name, 43 | prjString = zip.file(/.prj$/i)[0]; 44 | if(prjString) { 45 | proj4.defs('EPSGUSER', zip.file(prjString.name).asText()); 46 | try { 47 | EPSGUser = proj4('EPSGUSER'); 48 | } catch (e) { 49 | console.error('Unsuported Projection: ' + e); 50 | } 51 | } 52 | 53 | SHPParser.load(URL.createObjectURL(new Blob([zip.file(shpString).asArrayBuffer()])), shpLoader, returnData); 54 | DBFParser.load(URL.createObjectURL(new Blob([zip.file(dbfString).asArrayBuffer()])), encoding, dbfLoader, returnData); 55 | } 56 | 57 | reader.readAsArrayBuffer(url); 58 | } else { 59 | JSZipUtils.getBinaryContent(url, function(err, data) { 60 | if(err) throw err; 61 | 62 | var URL = window.URL || window.webkitURL, 63 | zip = new JSZip(data), 64 | shpString = zip.file(/.shp$/i)[0].name, 65 | dbfString = zip.file(/.dbf$/i)[0].name, 66 | prjString = zip.file(/.prj$/i)[0]; 67 | if(prjString) { 68 | proj4.defs('EPSGUSER', zip.file(prjString.name).asText()); 69 | try { 70 | EPSGUser = proj4('EPSGUSER'); 71 | } catch (e) { 72 | console.error('Unsuported Projection: ' + e); 73 | } 74 | } 75 | 76 | SHPParser.load(URL.createObjectURL(new Blob([zip.file(shpString).asArrayBuffer()])), shpLoader, returnData); 77 | DBFParser.load(URL.createObjectURL(new Blob([zip.file(dbfString).asArrayBuffer()])), encoding, dbfLoader, returnData); 78 | 79 | }); 80 | } 81 | }); 82 | } 83 | 84 | function loadEPSG(url, callback) { 85 | var script = document.createElement('script'); 86 | script.src = url; 87 | script.onreadystatechange = callback; 88 | script.onload = callback; 89 | document.getElementsByTagName('head')[0].appendChild(script); 90 | } 91 | 92 | function TransCoord(x, y) { 93 | if(proj4) 94 | var p = proj4(EPSGUser, EPSG4326 , [parseFloat(x), parseFloat(y)]); 95 | return {x: p[0], y: p[1]}; 96 | } 97 | 98 | function shpLoader(data, returnData) { 99 | inputData['shp'] = data; 100 | if(inputData['shp'] && inputData['dbf']) 101 | if(returnData) returnData( toGeojson(inputData) ); 102 | } 103 | 104 | function dbfLoader(data, returnData) { 105 | inputData['dbf'] = data; 106 | if(inputData['shp'] && inputData['dbf']) 107 | if(returnData) returnData( toGeojson(inputData) ); 108 | } 109 | 110 | function toGeojson(geojsonData) { 111 | var geojson = {}, 112 | features = [], 113 | feature, geometry, points; 114 | 115 | var shpRecords = geojsonData.shp.records; 116 | var dbfRecords = geojsonData.dbf.records; 117 | 118 | geojson.type = "FeatureCollection"; 119 | min = TransCoord(geojsonData.shp.minX, geojsonData.shp.minY); 120 | max = TransCoord(geojsonData.shp.maxX, geojsonData.shp.maxY); 121 | geojson.bbox = [ 122 | min.x, 123 | min.y, 124 | max.x, 125 | max.y 126 | ]; 127 | 128 | geojson.features = features; 129 | 130 | for (var i = 0; i < shpRecords.length; i++) { 131 | feature = {}; 132 | feature.type = 'Feature'; 133 | geometry = feature.geometry = {}; 134 | properties = feature.properties = dbfRecords[i]; 135 | 136 | // point : 1 , polyline : 3 , polygon : 5, multipoint : 8 137 | switch(shpRecords[i].shape.type) { 138 | case 1: 139 | geometry.type = "Point"; 140 | var reprj = TransCoord(shpRecords[i].shape.content.x, shpRecords[i].shape.content.y); 141 | geometry.coordinates = [ 142 | reprj.x, reprj.y 143 | ]; 144 | break; 145 | case 3: 146 | case 8: 147 | geometry.type = (shpRecords[i].shape.type == 3 ? "LineString" : "MultiPoint"); 148 | geometry.coordinates = []; 149 | for (var j = 0; j < shpRecords[i].shape.content.points.length; j+=2) { 150 | var reprj = TransCoord(shpRecords[i].shape.content.points[j], shpRecords[i].shape.content.points[j+1]); 151 | geometry.coordinates.push([reprj.x, reprj.y]); 152 | }; 153 | break; 154 | case 5: 155 | geometry.type = "Polygon"; 156 | geometry.coordinates = []; 157 | 158 | for (var pts = 0; pts < shpRecords[i].shape.content.parts.length; pts++) { 159 | var partsIndex = shpRecords[i].shape.content.parts[pts], 160 | part = [], 161 | dataset; 162 | 163 | for (var j = partsIndex*2; j < (shpRecords[i].shape.content.parts[pts+1]*2 || shpRecords[i].shape.content.points.length); j+=2) { 164 | var point = shpRecords[i].shape.content.points; 165 | var reprj = TransCoord(point[j], point[j+1]); 166 | part.push([reprj.x, reprj.y]); 167 | }; 168 | geometry.coordinates.push(part); 169 | 170 | }; 171 | break; 172 | default: 173 | } 174 | if("coordinates" in feature.geometry) features.push(feature); 175 | }; 176 | return geojson; 177 | } 178 | -------------------------------------------------------------------------------- /add-baidulayer-4.X/js/bism/BaiduLayer.js: -------------------------------------------------------------------------------- 1 | define(["dojo/_base/declare","dojo/_base/lang", "esri/layers/WebTileLayer", "esri/geometry/Extent", "esri/geometry/SpatialReference", "esri/layers/support/TileInfo","esri/geometry/Point"], 2 | function (declare, lang,WebTileLayer, Extent, SpatialReference, TileInfo,point) { 3 | return WebTileLayer.createSubclass({ 4 | 5 | normalizeCtorArgs: function(a, b) { 6 | return "string" === typeof a ? lang.mixin({ 7 | urlTemplate: a 8 | }, 9 | b || {}) : a 10 | }, 11 | getDefaults: function(a) { 12 | this.spatialReference = new SpatialReference({ 13 | wkid: 102113 14 | }); 15 | var b = new Extent(-20037508.342787, -20037508.342787, 20037508.342787, 20037508.342787, this.spatialReference); 16 | 17 | return lang.mixin(this.inherited(arguments), { 18 | fullExtent: b, 19 | tileInfo: new TileInfo({ 20 | size: 256, 21 | dpi: 96, 22 | format: "PNG8", 23 | compressionQuality: 0, 24 | origin: new point({ 25 | x:-2.0037508342787E7, 26 | y: 2.0037508342787E7, 27 | spatialReference: this.spatialReference 28 | }), 29 | spatialReference: this.spatialReference, 30 | lods: [ 31 | { level: 2, resolution: 39135.7584820001, scale: 147914381.897889 }, 32 | { level: 3, resolution: 19567.8792409999, scale: 73957190.948944 }, 33 | { level: 4, resolution: 9783.93962049996, scale: 36978595.474472 }, 34 | { level: 5, resolution: 4891.96981024998, scale: 18489297.737236 }, 35 | { level: 6, resolution: 2445.98490512499, scale: 9244648.868618 }, 36 | { level: 7, resolution: 1222.99245256249, scale: 4622324.434309 }, 37 | { level: 8, resolution: 611.49622628138, scale: 2311162.217155 }, 38 | { level: 9, resolution: 305.748113140558, scale: 1155581.108577 }, 39 | { level: 10, resolution: 152.874056570411, scale: 577790.554289 }, 40 | { level: 11, resolution: 76.4370282850732, scale: 288895.277144 }, 41 | { level: 12, resolution: 38.2185141425366, scale: 144447.638572 }, 42 | { level: 13, resolution: 19.1092570712683, scale: 72223.819286 }, 43 | { level: 14, resolution: 9.55462853563415, scale: 36111.909643 }, 44 | { level: 15, resolution: 4.77731426794937, scale: 18055.954822 }, 45 | { level: 16, resolution: 2.38865713397468, scale: 9027.977411 } 46 | 47 | ] 48 | }) 49 | }) 50 | }, 51 | properties: { 52 | copyright: { 53 | value: "", 54 | json: { 55 | write: !0 56 | } 57 | }, 58 | fullExtent: { 59 | json: { 60 | write: !0 61 | } 62 | }, 63 | legendEnabled: { 64 | json: { 65 | read: { 66 | source: ["showLegend"], 67 | reader: function(a, b) { 68 | return null != b.showLegend ? b.showLegend : !0 69 | } 70 | } 71 | } 72 | }, 73 | levelValues: { 74 | dependsOn: ["tileInfo"], 75 | get: function() { 76 | var a = []; 77 | if (!this.tileInfo) return null; 78 | this.tileInfo.lods.forEach(function(b) { 79 | a[b.level] = 80 | b.levelValue || b.level 81 | }, this); 82 | return a 83 | } 84 | }, 85 | operationalLayerType: "WebTiledLayer", 86 | popupEnabled: { 87 | json: { 88 | read: { 89 | source: ["disablePopup"], 90 | reader: function(a, b) { 91 | return null != b.disablePopup ? !b.disablePopup : !0 92 | } 93 | } 94 | } 95 | }, 96 | refreshInterval: { 97 | json: { 98 | write: !0 99 | } 100 | }, 101 | spatialReference: { 102 | type: SpatialReference, 103 | value: SpatialReference.WebMercator, 104 | json: { 105 | read: { 106 | source: ["spatialReference", "fullExtent.spatialReference"], 107 | reader: function(a, b) { 108 | return a || b.fullExtent && b.fullExtent.spatialReference && d.fromJSON(b.fullExtent.spatialReference) 109 | } 110 | } 111 | } 112 | }, 113 | subDomains: { 114 | value: null, 115 | json: { 116 | write: !0 117 | } 118 | }, 119 | tileInfo: { 120 | type: TileInfo, 121 | json: { 122 | write: !0 123 | } 124 | }, 125 | tileServers: { 126 | value: null, 127 | dependsOn: ["urlTemplate", "subDomains"], 128 | get: function() { 129 | var a="online1.map.bdimg.com"; 130 | return a 131 | } 132 | }, 133 | type: { 134 | value: "web-tile", 135 | json: { 136 | read: !1 137 | } 138 | }, 139 | urlPath: { 140 | dependsOn: ["urlTemplate"], 141 | get: function() { 142 | var a="baidu.layers" 143 | return a 144 | } 145 | }, 146 | urlTemplate: { 147 | get: function() { 148 | var a="online1.map.bdimg.com"; 149 | return a 150 | } 151 | }, 152 | url: { 153 | json: { 154 | write: !1 155 | } 156 | } 157 | }, 158 | getTileUrl: function (level,row, col) { 159 | var zoom =level- 1; 160 | var offsetX = Math.pow(2, zoom); 161 | var offsetY = offsetX - 1; 162 | var numX = col - offsetX; 163 | var numY = (-row) + offsetY; 164 | zoom =level+ 1; 165 | var url = "http://online1.map.bdimg.com/tile/?qt=tile&x=" + numX + "&y=" + numY + "&z=" + zoom + "&styles=pl"; 166 | return url; 167 | } 168 | // load: function() { 169 | // var a = this.loadFromPortal({ 170 | // supportedTypes: ["WMTS"] 171 | // }).then(function() { 172 | // }.bind(this)); 173 | // this.addResolvingPromise(a); 174 | // return this 175 | // } 176 | }) 177 | }); -------------------------------------------------------------------------------- /shp-add-map/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Demo page - shp2geojson.js 5 | 6 | 7 | 8 | 9 | 10 | Fork me on GitHub 11 |
12 |
13 | 14 |
15 | 16 |
17 | 18 | 24 |
25 | 26 | 27 |
AttributeValue
Close
28 | 29 |
30 | 31 |
32 |
33 | 34 |
35 |
36 | 37 | Upload zip file 38 |
39 |
Remove All Features
40 |
41 | 42 |
43 |
44 | 45 |
46 | 47 |
48 | 49 |
50 |
51 | Upload zip file 52 | 53 | 54 |
55 | 56 |
57 | 58 |
59 |
60 |
EPSG
61 | 62 |
63 |
64 |
Encoding
65 | 66 |
67 |
68 | 69 |
70 | 71 |
72 | Download TestData 73 |
74 | 75 |
Preview 76 | 77 |
78 | 79 |
80 |
81 | 84 |
85 |
86 |
Cancel
87 | 88 |
89 |
90 |
91 |
Loading
92 |
93 | 94 |
95 | 96 | 109 | 110 |
111 | 112 |
113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 250 | 251 | -------------------------------------------------------------------------------- /tianditu4.X/tianditu4490.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Demo For WMTS(天地图) JS API 4.3 11 | 12 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 |
33 |
34 | 35 | 219 | 220 | 221 | -------------------------------------------------------------------------------- /shp-add-map/preprocess.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Inspired by the shp.js , dbf.js by Mano Marks 3 | * 4 | * I found there were something wrong to show chinese characters from DBF file, 5 | * so i added some code that is needed to deal with this problem. 6 | * 7 | * Created by Gipong 8 | * 9 | */ 10 | 11 | var geojsonData = {}; 12 | 13 | // Shapefile parser, following the specification at 14 | // http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf 15 | SHP = { 16 | NULL: 0, 17 | POINT: 1, 18 | POLYLINE: 3, 19 | POLYGON: 5 20 | }; 21 | 22 | SHP.getShapeName = function(id) { 23 | for (name in this) { 24 | if (id === this[name]) { 25 | return name; 26 | } 27 | } 28 | }; 29 | 30 | SHPParser = function() {}; 31 | 32 | SHPParser.load = function(url, callback, returnData) { 33 | var xhr = new XMLHttpRequest(); 34 | xhr.open('GET', url); 35 | xhr.responseType = 'arraybuffer'; 36 | xhr.onload = function() { 37 | geojsonData['shp'] = new SHPParser().parse(xhr.response,url); 38 | callback(geojsonData['shp'], returnData); 39 | URL.revokeObjectURL(url); 40 | }; 41 | xhr.onerror = onerror; 42 | xhr.send(null); 43 | }; 44 | 45 | SHPParser.prototype.parse = function(arrayBuffer,url) { 46 | var o = {}, 47 | dv = new DataView(arrayBuffer), 48 | idx = 0; 49 | o.fileName = url; 50 | o.fileCode = dv.getInt32(idx, false); 51 | if (o.fileCode != 0x0000270a) { 52 | throw (new Error("Unknown file code: " + o.fileCode)); 53 | } 54 | idx += 6*4; 55 | o.wordLength = dv.getInt32(idx, false); 56 | o.byteLength = o.wordLength * 2; 57 | idx += 4; 58 | o.version = dv.getInt32(idx, true); 59 | idx += 4; 60 | o.shapeType = dv.getInt32(idx, true); 61 | idx += 4; 62 | o.minX = dv.getFloat64(idx, true); 63 | o.minY = dv.getFloat64(idx+8, true); 64 | o.maxX = dv.getFloat64(idx+16, true); 65 | o.maxY = dv.getFloat64(idx+24, true); 66 | o.minZ = dv.getFloat64(idx+32, true); 67 | o.maxZ = dv.getFloat64(idx+40, true); 68 | o.minM = dv.getFloat64(idx+48, true); 69 | o.maxM = dv.getFloat64(idx+56, true); 70 | idx += 8*8; 71 | o.records = []; 72 | while (idx < o.byteLength) { 73 | var record = {}; 74 | record.number = dv.getInt32(idx, false); 75 | idx += 4; 76 | record.length = dv.getInt32(idx, false); 77 | idx += 4; 78 | try { 79 | record.shape = this.parseShape(dv, idx, record.length); 80 | } catch(e) { 81 | console.log(e, record); 82 | } 83 | idx += record.length * 2; 84 | o.records.push(record); 85 | } 86 | return o; 87 | }; 88 | 89 | SHPParser.prototype.parseShape = function(dv, idx, length) { 90 | var i=0, 91 | c=null, 92 | shape = {}; 93 | shape.type = dv.getInt32(idx, true); 94 | idx += 4; 95 | var byteLen = length * 2; 96 | switch (shape.type) { 97 | case SHP.NULL: // Null 98 | break; 99 | 100 | case SHP.POINT: // Point (x,y) 101 | shape.content = { 102 | x: dv.getFloat64(idx, true), 103 | y: dv.getFloat64(idx+8, true) 104 | }; 105 | break; 106 | case SHP.POLYLINE: // Polyline (MBR, partCount, pointCount, parts, points) 107 | case SHP.POLYGON: // Polygon (MBR, partCount, pointCount, parts, points) 108 | c = shape.content = { 109 | minX: dv.getFloat64(idx, true), 110 | minY: dv.getFloat64(idx+8, true), 111 | maxX: dv.getFloat64(idx+16, true), 112 | maxY: dv.getFloat64(idx+24, true), 113 | parts: new Int32Array(dv.getInt32(idx+32, true)), 114 | points: new Float64Array(dv.getInt32(idx+36, true)*2) 115 | }; 116 | idx += 40; 117 | for (i=0; i 2) { 227 | response_handler.pop(); 228 | responseHeader = response_handler.join('\r'); 229 | responseHeader = responseHeader.slice(32, responseHeader.length); 230 | } else { 231 | responseHeader = response_handler[0]; 232 | responseHeader = responseHeader.slice(32, responseHeader.length); 233 | offset = 2; 234 | } 235 | 236 | var charString = [], 237 | count = 0, 238 | index = 0, 239 | sum = (responseHeader.length+1)/32; 240 | 241 | while(responseHeader.length > 0) { 242 | while(count < 10) { 243 | try { 244 | if( encodeURIComponent(responseHeader[z]).match(/%[A-F\d]{2}/g) ) { 245 | if( encodeURIComponent(responseHeader[z]).match(/%[A-F\d]{2}/g).length > 1 ) { 246 | count += offset; 247 | z++; 248 | } else { 249 | count += 1; 250 | z++; 251 | } 252 | } else { 253 | count += 1; 254 | z++; 255 | } 256 | } catch(error) { // avoid malformed URI 257 | count += 1; 258 | z++; 259 | } 260 | } 261 | 262 | charString.push(responseHeader.slice(0, 10).replace(/\0/g, '')) 263 | responseHeader = responseHeader.slice(32, responseHeader.length); 264 | } 265 | 266 | while (true) { 267 | var field = {}, 268 | nameArray = []; 269 | 270 | for (var i = 0, z=0; i < 10; i++) { 271 | var letter = dv.getUint8(idx); 272 | if (letter != 0) nameArray.push(String.fromCharCode(letter)); 273 | idx += 1; 274 | } 275 | 276 | field.name = charString[index++]; 277 | idx += 1; 278 | field.type = String.fromCharCode(dv.getUint8(idx)); 279 | idx += 1; 280 | // Skip field data address 281 | idx += 4; 282 | field.fieldLength = dv.getUint8(idx); 283 | idx += 1; 284 | //field.decimalCount = dv.getUint8(idx); 285 | idx += 1; 286 | // Skip reserved bytes multi-user dBASE. 287 | idx += 2; 288 | field.workAreaId = dv.getUint8(idx); 289 | idx += 1; 290 | // Skip reserved bytes multi-user dBASE. 291 | idx += 2; 292 | field.setFieldFlag = dv.getUint8(idx); 293 | idx += 1; 294 | // Skip reserved bytes. 295 | idx += 7; 296 | field.indexFieldFlag = dv.getUint8(idx); 297 | idx += 1; 298 | o.fields.push(field); 299 | var test = dv.getUint8(idx); 300 | // Checks for end of field descriptor array. Valid .dbf files will have this 301 | // flag. 302 | if (dv.getUint8(idx) == 0x0D) break; 303 | } 304 | 305 | idx += 1; 306 | o.fieldpos = idx; 307 | o.records = []; 308 | 309 | responseText = response.split('\r')[response.split('\r').length-1]; 310 | 311 | for (var i = 0; i < o.numberOfRecords; i++) { 312 | responseText = responseText.slice(1, responseText.length); 313 | var record = {}; 314 | 315 | for (var j = 0; j < o.fields.length; j++) { 316 | var charString = [], 317 | count = 0, 318 | z = 0; 319 | 320 | while(count < o.fields[j].fieldLength) { 321 | try { 322 | if( encodeURIComponent(responseText[z]).match(/%[A-F\d]{2}/g) ) { 323 | if( encodeURIComponent(responseText[z]).match(/%[A-F\d]{2}/g).length > 1 ) { 324 | count += offset; 325 | z++; 326 | check = 1; 327 | } else { 328 | count += 1; 329 | z++; 330 | } 331 | } else { 332 | count += 1; 333 | z++; 334 | } 335 | } catch(error) { // avoid malformed URI 336 | count += 1; 337 | z++; 338 | } 339 | } 340 | 341 | charString.push(responseText.slice(0, z).replace(/\0/g, '')); 342 | responseText = responseText.slice(z, responseText.length); 343 | 344 | if(charString.join('').trim().match(/\d{1}\.\d{11}e\+\d{3}/g)) { 345 | record[o.fields[j].name] = parseFloat(charString.join('').trim()); 346 | } else { 347 | record[o.fields[j].name] = charString.join('').trim(); 348 | } 349 | 350 | } 351 | o.records.push(record); 352 | } 353 | return o; 354 | }; -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer-arcgis-parser/terraformer-arcgis-parser.js: -------------------------------------------------------------------------------- 1 | /* globals Terraformer */ 2 | (function (root, factory) { 3 | 4 | // Node. 5 | if(typeof module === 'object' && typeof module.exports === 'object') { 6 | exports = module.exports = factory(require('terraformer')); 7 | } 8 | 9 | // Browser Global. 10 | if(typeof root.navigator === "object") { 11 | if (!root.Terraformer){ 12 | throw new Error("Terraformer.ArcGIS requires the core Terraformer library. https://github.com/esri/Terraformer"); 13 | } 14 | root.Terraformer.ArcGIS = factory(root.Terraformer); 15 | } 16 | 17 | }(this, function(Terraformer) { 18 | var exports = {}; 19 | 20 | // https://github.com/Esri/terraformer-arcgis-parser/issues/10 21 | function decompressGeometry(str) { 22 | var xDiffPrev = 0; 23 | var yDiffPrev = 0; 24 | var points = []; 25 | var x, y; 26 | var strings; 27 | var coefficient; 28 | 29 | // Split the string into an array on the + and - characters 30 | strings = str.match(/((\+|\-)[^\+\-]+)/g); 31 | 32 | // The first value is the coefficient in base 32 33 | coefficient = parseInt(strings[0], 32); 34 | 35 | for (var j = 1; j < strings.length; j += 2) { 36 | // j is the offset for the x value 37 | // Convert the value from base 32 and add the previous x value 38 | x = (parseInt(strings[j], 32) + xDiffPrev); 39 | xDiffPrev = x; 40 | 41 | // j+1 is the offset for the y value 42 | // Convert the value from base 32 and add the previous y value 43 | y = (parseInt(strings[j + 1], 32) + yDiffPrev); 44 | yDiffPrev = y; 45 | 46 | points.push([x / coefficient, y / coefficient]); 47 | } 48 | 49 | return points; 50 | } 51 | 52 | // checks if the first and last points of a ring are equal and closes the ring 53 | function closeRing(coordinates) { 54 | if (!pointsEqual(coordinates[0], coordinates[coordinates.length - 1])) { 55 | coordinates.push(coordinates[0]); 56 | } 57 | return coordinates; 58 | } 59 | 60 | // checks if 2 x,y points are equal 61 | function pointsEqual(a, b) { 62 | for (var i = 0; i < a.length; i++) { 63 | if (a[i] !== b[i]) { 64 | return false; 65 | } 66 | } 67 | return true; 68 | } 69 | 70 | // shallow object clone for feature properties and attributes 71 | // from http://jsperf.com/cloning-an-object/2 72 | function clone(obj) { 73 | var target = {}; 74 | for (var i in obj) { 75 | if (obj.hasOwnProperty(i)) { 76 | target[i] = obj[i]; 77 | } 78 | } 79 | return target; 80 | } 81 | 82 | // determine if polygon ring coordinates are clockwise. clockwise signifies outer ring, counter-clockwise an inner ring 83 | // or hole. this logic was found at http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon- 84 | // points-are-in-clockwise-order 85 | function ringIsClockwise(ringToTest) { 86 | var total = 0,i = 0; 87 | var rLength = ringToTest.length; 88 | var pt1 = ringToTest[i]; 89 | var pt2; 90 | for (i; i < rLength - 1; i++) { 91 | pt2 = ringToTest[i + 1]; 92 | total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]); 93 | pt1 = pt2; 94 | } 95 | return (total >= 0); 96 | } 97 | 98 | // This function ensures that rings are oriented in the right directions 99 | // outer rings are clockwise, holes are counterclockwise 100 | function orientRings(poly){ 101 | var output = []; 102 | var polygon = poly.slice(0); 103 | var outerRing = closeRing(polygon.shift().slice(0)); 104 | if(outerRing.length >= 4){ 105 | if(!ringIsClockwise(outerRing)){ 106 | outerRing.reverse(); 107 | } 108 | 109 | output.push(outerRing); 110 | 111 | for (var i = 0; i < polygon.length; i++) { 112 | var hole = closeRing(polygon[i].slice(0)); 113 | if(hole.length >= 4){ 114 | if(ringIsClockwise(hole)){ 115 | hole.reverse(); 116 | } 117 | output.push(hole); 118 | } 119 | } 120 | } 121 | 122 | return output; 123 | } 124 | 125 | // This function flattens holes in multipolygons to one array of polygons 126 | // [ 127 | // [ 128 | // [ array of outer coordinates ] 129 | // [ hole coordinates ] 130 | // [ hole coordinates ] 131 | // ], 132 | // [ 133 | // [ array of outer coordinates ] 134 | // [ hole coordinates ] 135 | // [ hole coordinates ] 136 | // ], 137 | // ] 138 | // becomes 139 | // [ 140 | // [ array of outer coordinates ] 141 | // [ hole coordinates ] 142 | // [ hole coordinates ] 143 | // [ array of outer coordinates ] 144 | // [ hole coordinates ] 145 | // [ hole coordinates ] 146 | // ] 147 | function flattenMultiPolygonRings(rings){ 148 | var output = []; 149 | for (var i = 0; i < rings.length; i++) { 150 | var polygon = orientRings(rings[i]); 151 | for (var x = polygon.length - 1; x >= 0; x--) { 152 | var ring = polygon[x].slice(0); 153 | output.push(ring); 154 | } 155 | } 156 | return output; 157 | } 158 | 159 | function coordinatesContainCoordinates(outer, inner){ 160 | var intersects = Terraformer.Tools.arraysIntersectArrays(outer, inner); 161 | var contains = Terraformer.Tools.coordinatesContainPoint(outer, inner[0]); 162 | if(!intersects && contains){ 163 | return true; 164 | } 165 | return false; 166 | } 167 | 168 | // do any polygons in this array contain any other polygons in this array? 169 | // used for checking for holes in arcgis rings 170 | function convertRingsToGeoJSON(rings){ 171 | var outerRings = []; 172 | var holes = []; 173 | 174 | // for each ring 175 | for (var r = 0; r < rings.length; r++) { 176 | var ring = closeRing(rings[r].slice(0)); 177 | if(ring.length < 4){ 178 | continue; 179 | } 180 | // is this ring an outer ring? is it clockwise? 181 | if(ringIsClockwise(ring)){ 182 | var polygon = [ ring ]; 183 | outerRings.push(polygon); // push to outer rings 184 | } else { 185 | holes.push(ring); // counterclockwise push to holes 186 | } 187 | } 188 | 189 | // while there are holes left... 190 | while(holes.length){ 191 | // pop a hole off out stack 192 | var hole = holes.pop(); 193 | var matched = false; 194 | 195 | // loop over all outer rings and see if they contain our hole. 196 | for (var x = outerRings.length - 1; x >= 0; x--) { 197 | var outerRing = outerRings[x][0]; 198 | if(coordinatesContainCoordinates(outerRing, hole)){ 199 | // the hole is contained push it into our polygon 200 | outerRings[x].push(hole); 201 | 202 | // we matched the hole 203 | matched = true; 204 | 205 | // stop checking to see if other outer rings contian this hole 206 | break; 207 | } 208 | } 209 | 210 | // no outer rings contain this hole turn it into and outer ring (reverse it) 211 | if(!matched){ 212 | outerRings.push([ hole.reverse() ]); 213 | } 214 | } 215 | 216 | if(outerRings.length === 1){ 217 | return { 218 | type: "Polygon", 219 | coordinates: outerRings[0] 220 | }; 221 | } else { 222 | return { 223 | type: "MultiPolygon", 224 | coordinates: outerRings 225 | }; 226 | } 227 | } 228 | 229 | // ArcGIS -> GeoJSON 230 | function parse(arcgis, options){ 231 | var geojson = {}; 232 | 233 | options = options || {}; 234 | options.idAttribute = options.idAttribute || undefined; 235 | 236 | if(typeof arcgis.x === 'number' && typeof arcgis.y === 'number'){ 237 | geojson.type = "Point"; 238 | geojson.coordinates = [arcgis.x, arcgis.y]; 239 | if (arcgis.z || arcgis.m){ 240 | geojson.coordinates.push(arcgis.z); 241 | } 242 | if (arcgis.m){ 243 | geojson.coordinates.push(arcgis.m); 244 | } 245 | } 246 | 247 | if(arcgis.points){ 248 | geojson.type = "MultiPoint"; 249 | geojson.coordinates = arcgis.points.slice(0); 250 | } 251 | 252 | if(arcgis.paths) { 253 | if(arcgis.paths.length === 1){ 254 | geojson.type = "LineString"; 255 | geojson.coordinates = arcgis.paths[0].slice(0); 256 | } else { 257 | geojson.type = "MultiLineString"; 258 | geojson.coordinates = arcgis.paths.slice(0); 259 | } 260 | } 261 | 262 | if(arcgis.rings) { 263 | geojson = convertRingsToGeoJSON(arcgis.rings.slice(0)); 264 | } 265 | 266 | if(arcgis.compressedGeometry || arcgis.geometry || arcgis.attributes) { 267 | geojson.type = "Feature"; 268 | 269 | if(arcgis.compressedGeometry){ 270 | arcgis.geometry = { 271 | paths: [ 272 | decompressGeometry(arcgis.compressedGeometry) 273 | ] 274 | }; 275 | } 276 | 277 | geojson.geometry = (arcgis.geometry) ? parse(arcgis.geometry) : null; 278 | geojson.properties = (arcgis.attributes) ? clone(arcgis.attributes) : null; 279 | if(arcgis.attributes) { 280 | geojson.id = arcgis.attributes[options.idAttribute] || arcgis.attributes.OBJECTID || arcgis.attributes.FID; 281 | } 282 | } 283 | 284 | var inputSpatialReference = (arcgis.geometry) ? arcgis.geometry.spatialReference : arcgis.spatialReference; 285 | 286 | //convert spatial ref if needed 287 | if(inputSpatialReference && inputSpatialReference.wkid === 102100){ 288 | geojson = Terraformer.toGeographic(geojson); 289 | } 290 | 291 | return new Terraformer.Primitive(geojson); 292 | } 293 | 294 | // GeoJSON -> ArcGIS 295 | function convert(geojson, options){ 296 | var spatialReference; 297 | 298 | options = options || {}; 299 | var idAttribute = options.idAttribute || "OBJECTID"; 300 | 301 | if(options.sr){ 302 | spatialReference = { wkid: options.sr }; 303 | } else if (geojson && geojson.crs === Terraformer.MercatorCRS) { 304 | spatialReference = { wkid: 102100 }; 305 | } else { 306 | spatialReference = { wkid: 4326 }; 307 | } 308 | 309 | var result = {}; 310 | var i; 311 | 312 | switch(geojson.type){ 313 | case "Point": 314 | result.x = geojson.coordinates[0]; 315 | result.y = geojson.coordinates[1]; 316 | if(geojson.coordinates[2]) { 317 | result.z = geojson.coordinates[2]; 318 | } 319 | if(geojson.coordinates[3]) { 320 | result.m = geojson.coordinates[3]; 321 | } 322 | result.spatialReference = spatialReference; 323 | break; 324 | case "MultiPoint": 325 | result.points = geojson.coordinates.slice(0); 326 | result.spatialReference = spatialReference; 327 | break; 328 | case "LineString": 329 | result.paths = [geojson.coordinates.slice(0)]; 330 | result.spatialReference = spatialReference; 331 | break; 332 | case "MultiLineString": 333 | result.paths = geojson.coordinates.slice(0); 334 | result.spatialReference = spatialReference; 335 | break; 336 | case "Polygon": 337 | result.rings = orientRings(geojson.coordinates.slice(0)); 338 | result.spatialReference = spatialReference; 339 | break; 340 | case "MultiPolygon": 341 | result.rings = flattenMultiPolygonRings(geojson.coordinates.slice(0)); 342 | result.spatialReference = spatialReference; 343 | break; 344 | case "Feature": 345 | if(geojson.geometry) { 346 | result.geometry = convert(geojson.geometry, options); 347 | } 348 | result.attributes = (geojson.properties) ? clone(geojson.properties) : {}; 349 | result.attributes[idAttribute] = geojson.id; 350 | break; 351 | case "FeatureCollection": 352 | result = []; 353 | for (i = 0; i < geojson.features.length; i++){ 354 | result.push(convert(geojson.features[i], options)); 355 | } 356 | break; 357 | case "GeometryCollection": 358 | result = []; 359 | for (i = 0; i < geojson.geometries.length; i++){ 360 | result.push(convert(geojson.geometries[i], options)); 361 | } 362 | break; 363 | } 364 | 365 | return result; 366 | } 367 | 368 | function parseCompressedGeometry(string){ 369 | return new Terraformer.LineString(decompressGeometry(string)); 370 | } 371 | 372 | exports.parse = parse; 373 | exports.convert = convert; 374 | exports.toGeoJSON = parse; 375 | exports.fromGeoJSON = convert; 376 | exports.parseCompressedGeometry = parseCompressedGeometry; 377 | 378 | return exports; 379 | })); 380 | -------------------------------------------------------------------------------- /shp-add-map/src/geojsonlayer.js: -------------------------------------------------------------------------------- 1 | define([ 2 | "dojo/_base/declare", 3 | "esri/graphic", 4 | "esri/layers/GraphicsLayer", 5 | "esri/InfoTemplate", 6 | "esri/graphicsUtils", 7 | "esri/Color", 8 | "esri/symbols/SimpleMarkerSymbol", 9 | "esri/symbols/SimpleLineSymbol", 10 | "esri/symbols/SimpleFillSymbol", 11 | "esri/renderers/SimpleRenderer", 12 | "esri/SpatialReference", 13 | "esri/geometry/webMercatorUtils", 14 | "esri/request", 15 | "esri/config", 16 | "dojo/_base/url", 17 | "dojo/_base/lang" 18 | ], function (declare, Graphic, GraphicsLayer, InfoTemplate, graphicsUtils, Color, SimpleMarkerSymbol, 19 | SimpleLineSymbol, SimpleFillSymbol, SimpleRenderer, SpatialReference, webMercatorUtils, esriRequest, esriConfig, Url, lang 20 | ) { 21 | return declare([GraphicsLayer], { 22 | 23 | // Required Terrformer library reference 24 | _terrafomer: (typeof Terraformer !== 'undefined') ? Terraformer : null, 25 | 26 | constructor: function (options) { 27 | // options: 28 | // url: String 29 | // Path to file or server endpoint. Server must be on the same domain or cors enabled. Or use a proxy. 30 | // data: Object[] 31 | // Optional: FeatureCollection of GeoJson features. This will override url if both are provided. 32 | // maxdraw: Number 33 | // Optional: The maximum graphics to render. Default is 1000. 34 | this._validState = true; 35 | // First look for url 36 | this._url = options.url; 37 | // Accept data as geojson features array. This will override options.url! 38 | this._data = options.data; 39 | // GeoJSON spatial reference (not optional) 40 | this._inSpatialReference = new SpatialReference({wkid: 4326}); // Data must be in Geographic Coordinates 41 | // GeoJSON transformation (optional) 42 | this._outSpatialReference = null; 43 | // Default popup 44 | if (options.infoTemplate !== false) { 45 | this.setInfoTemplate(options.infoTemplate || new InfoTemplate("GeoJSON Data", "${*}")); 46 | } 47 | // Renderer 48 | if (options.renderer) { 49 | this.renderer = options.renderer; 50 | } 51 | // Default symbols 52 | this._setDefaultSymbols(); 53 | // Enable browser to make cross-domain requests 54 | this._setCorsSevers(); 55 | this._setXhrDefaults(10000); 56 | // Manage drawing 57 | this._maxDraw = options.maxdraw || 1000; // default to 1000 graphics 58 | this._drawCount = 0; 59 | this._drawCountTotal = 0; 60 | // Extended public properties 61 | this.extent = null; 62 | // Graphics layer does not call onLoad natively but we'll call it after features have been added to layer 63 | if (options.onLoad && typeof options.onLoad === 'function') { 64 | this.onLoad = options.onLoad; 65 | } 66 | // Make sure the environment is good to go! 67 | this._updateState(); 68 | }, 69 | 70 | _setDefaultSymbols: function () { 71 | function getRandomColor(mainColor, transparency) { 72 | function getRandomInt(min, max) { 73 | return Math.floor(Math.random() * (max - min + 1)) + min; 74 | } 75 | switch (mainColor) { 76 | case "red": 77 | return new Color([getRandomInt(150, 255), getRandomInt(0, 255), getRandomInt(0, 255), transparency]); 78 | case "green": 79 | return new Color([getRandomInt(0, 155), getRandomInt(150, 255), getRandomInt(0, 155), transparency]); 80 | case "blue": 81 | return new Color([getRandomInt(0, 255), getRandomInt(0, 255), getRandomInt(150, 255), transparency]); 82 | } 83 | } 84 | // Random colors 85 | this._simplePointSym = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 8, 86 | new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, getRandomColor("blue", 0.5), 1), 87 | getRandomColor("blue", 0.75)); 88 | this._simpleLineSym = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, getRandomColor("red", 0.9), 2); 89 | this._simplePolygonSym = new SimpleFillSymbol("solid", 90 | new SimpleLineSymbol("solid", new Color([50, 50, 50, 0.15]), 1), 91 | getRandomColor("green", 0.15)); 92 | // Option to hardcod colors here 93 | // this._simplePointSym = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 8, 94 | // new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([150, 150, 150]), 0.5), 95 | // new Color([50, 130, 255, 0.75])); 96 | // this._simpleLineSym = new SimpleLineSymbol("solid", new Color([255, 50, 50, 0.75]), 2); 97 | // this._simplePolygonSym = new SimpleFillSymbol("solid", 98 | // new SimpleLineSymbol("solid", new Color([0, 0, 0, 0.10]), 1), 99 | // new Color([150, 255, 150, 0.10])); 100 | }, 101 | 102 | _setCorsSevers: function () { 103 | // Allow browser to make cross-domain requests 104 | esriConfig.defaults.io.corsEnabledServers.push("http://sampleserver6.arcgisonline.com"); 105 | // Add server 106 | if (this._url) { 107 | var url = new Url(this._url), 108 | scheme = url.scheme, 109 | host = url.host, 110 | port = url.port, 111 | server = scheme + "://" + host; // + "/"; // + (port ? port : ""); // TODO 112 | if (scheme && host) { 113 | esriConfig.defaults.io.corsEnabledServers.push(server); 114 | } 115 | } 116 | }, 117 | 118 | _setXhrDefaults: function (postSize) { 119 | esriConfig.defaults.io.postLength = postSize; // max size of post request 120 | }, 121 | 122 | _updateState: function () { 123 | if (!this._inSpatialReference) { 124 | this._validState = false; 125 | console.error("GeoJsonLayer Error: Invalid SpatialReference."); 126 | } 127 | if (!this._terrafomer) { 128 | this._validState = false; 129 | console.error("GeoJsonLayer Error: Invalid Terraformer reference. Please add a reference to your html page."); 130 | } 131 | }, 132 | 133 | // GraphicLayer overrides 134 | _setMap: function (map, surface) { 135 | var div = this.inherited(arguments); 136 | // Check spatial reference 137 | if (!this._validState) { 138 | return div; 139 | } 140 | // Set sr if need to project 141 | this._outSpatialReference = map.spatialReference; 142 | // Load GeoJSON as graphics 143 | this._loadGeoJson(); 144 | // Return div - sets this.id 145 | return div; 146 | }, 147 | 148 | _unsetMap: function () { 149 | return this.inherited(arguments); 150 | }, 151 | 152 | add: function (graphic) { 153 | if (!this._validState) { 154 | return; 155 | } 156 | // Can do more with graphic if needed 157 | this.inherited(arguments); 158 | this._incrementDrawCount(); 159 | return; 160 | }, 161 | 162 | clear: function () { 163 | this._drawCount = 0; 164 | this._drawCountMax = 0; 165 | return this.inherited(arguments); 166 | }, 167 | 168 | // GeoJsonLayer class functions 169 | _loadGeoJson: function () { 170 | if (this._data) { 171 | // Load data 172 | this._getGeoJson(this._data); 173 | } else if (this._url) { 174 | // XHR request 175 | this._getGeoJsonXhr(this._url); 176 | } 177 | }, 178 | 179 | _getGeoJsonXhr: function (url) { 180 | // xhr request to get data 181 | var requestHandle = esriRequest({ 182 | url: url, 183 | handleAs: "json" 184 | }); 185 | requestHandle.then(lang.hitch(this, this._getGeoJson), 186 | lang.hitch(this, this._errorGetGeoJsonXhr)); 187 | }, 188 | 189 | _getGeoJson: function (geojson) { 190 | // Check data 191 | if (geojson.type !== "FeatureCollection" || !geojson.features) { 192 | console.error("GeoJsonLayer Error: Invalid GeoJSON FeatureCollection. Check url or data structure."); 193 | return; 194 | } 195 | // Convert GeoJSON to ArcGIS JSON 196 | var arcgisJson = this._terraformerConverter(geojson); 197 | // Add graphics to layer 198 | this._addGraphics(arcgisJson); 199 | }, 200 | 201 | // GeoJSON to ArcGIS JSON 202 | _terraformerConverter: function (geojson) { 203 | var json, 204 | arcgis; 205 | // Convert the geojson object to a Primitive json representation 206 | json = new this._terrafomer.Primitive(geojson); 207 | // Convert to ArcGIS JSON 208 | arcgis = this._terrafomer.ArcGIS.convert(json); 209 | return arcgis; 210 | }, 211 | 212 | _errorGetGeoJsonXhr: function (e) { 213 | console.error("GeoJsonLayer Error: Couldn't load GeoJSON. Check url. File must be on the same domain or server must be CORS enabled.\n\n" + e); 214 | }, 215 | 216 | _incrementDrawCount: function () { 217 | this._drawCount++; 218 | if (this._drawCount === this._drawCountTotal) { 219 | this._updateLayerExtent(); 220 | this.onUpdateEnd(); 221 | } 222 | }, 223 | 224 | _decrementDrawCount: function () { 225 | this._drawCountTotal--; 226 | }, 227 | 228 | _updateLayerExtent: function () { 229 | var extent; 230 | if (this.graphics.length) { 231 | extent = graphicsUtils.graphicsExtent(this.graphics); 232 | } 233 | this.extent = extent; 234 | }, 235 | 236 | // Type functions 237 | _getEsriSymbol: function (geometryType) { 238 | var sym; 239 | switch (geometryType) { 240 | case "point": 241 | sym = this._simplePointSym; 242 | break; 243 | case "multipoint": 244 | sym = this._simplePointSym; 245 | break; 246 | case "polyline": 247 | sym = this._simpleLineSym; 248 | break; 249 | case "polygon": 250 | sym = this._simplePolygonSym; 251 | break; 252 | case "extent": 253 | sym = this._simplePolygonSym; 254 | break; 255 | } 256 | return sym; 257 | }, 258 | 259 | _addGraphicToLayer: function (graphic) { 260 | // Add or project and then add graphic 261 | if (this._inSpatialReference.wkid === 4326 || this._inSpatialReference.wkid === 102100) { 262 | // ArcGIS API automatically translates between these! 263 | // if (graphic.geometry.spatialReference.wkid === 4326) { 264 | // graphic.setGeometry(webMercatorUtils.geographicToWebMercator(graphic.geometry)); 265 | // } 266 | // Add graphic directly 267 | this.add(graphic); 268 | } 269 | }, 270 | 271 | _createGraphic: function (arcgisJson) { 272 | var graphic; 273 | // This magically sets geometry type! 274 | graphic = new Graphic(arcgisJson); 275 | // Set the correct symbol based on type and render - NOTE: Only supports simple renderers 276 | if (this.renderer && this.renderer.symbol) { 277 | //graphic.setSymbol(this.render.getSymbol(graphic)); // use for complex renderers 278 | graphic.setSymbol(this.renderer.symbol); 279 | } else { 280 | graphic.setSymbol(this._getEsriSymbol(graphic.geometry.type)); 281 | } 282 | // Update SR because terraformer sets incorrect spatial reference 283 | graphic.geometry.setSpatialReference(this._inSpatialReference); // NOTE: Has to match features! 284 | return graphic; 285 | }, 286 | 287 | _addGraphics: function (arcgisJson) { 288 | var i, 289 | feature, 290 | graphic; 291 | // Limit size of data that can be drawn 292 | if (arcgisJson.length > this._maxDraw) { 293 | this._drawCountTotal = this._maxDraw; 294 | console.warn("GeoJsonLayer Warning: Large dataset detected. Only drawing the first " + this._maxDraw + " features!"); 295 | } else { 296 | this._drawCountTotal = arcgisJson.length; 297 | } 298 | // Add graphics to the layer with symbols, project if needed 299 | for (i = 0; i < this._drawCountTotal; i++) { 300 | feature = arcgisJson[i]; 301 | // Create graphic - magically sets the geometry type! 302 | graphic = this._createGraphic(feature); 303 | // Add to layer 304 | this._addGraphicToLayer(graphic); 305 | } 306 | // Call onLoad 307 | // emit mixes in `layer` and `target` properties as event object 308 | // onLoad provided via constructor just returns `layer` object 309 | this.onLoad(this); 310 | } 311 | }); 312 | }); -------------------------------------------------------------------------------- /shp-add-map/vendor/terraformer/terraformer.min.js: -------------------------------------------------------------------------------- 1 | /*! Terraformer JS - 1.0.3 - 2014-02-24 2 | * https://github.com/esri/Terraformer 3 | * Copyright (c) 2014 Environmental Systems Research Institute, Inc. 4 | * Licensed MIT */!function(a,b){"object"==typeof module&&"object"==typeof module.exports&&(exports=module.exports=b()),"object"==typeof window&&(a.Terraformer=b())}(this,function(){function a(a){return"[object Array]"===Object.prototype.toString.call(a)}function b(){var a=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,a)}function c(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function d(a){if(a.type)switch(a.type){case"Point":return[a.coordinates[0],a.coordinates[1],a.coordinates[0],a.coordinates[1]];case"MultiPoint":return g(a.coordinates);case"LineString":return g(a.coordinates);case"MultiLineString":return e(a.coordinates);case"Polygon":return e(a.coordinates);case"MultiPolygon":return f(a.coordinates);case"Feature":return a.geometry?d(a.geometry):null;case"FeatureCollection":return h(a);case"GeometryCollection":return i(a);default:throw new Error("Unknown type: "+a.type)}return null}function e(a){for(var b=null,c=null,d=null,e=null,f=0;fj&&(b=j),null===c?c=j:j>c&&(c=j),null===d?d=k:d>k&&(d=k),null===e?e=k:k>e&&(e=k)}return[b,d,c,e]}function f(a){for(var b=null,c=null,d=null,e=null,f=0;fl&&(b=l),null===c?c=l:l>c&&(c=l),null===d?d=m:d>m&&(d=m),null===e?e=m:m>e&&(e=m)}return[b,d,c,e]}function g(a){for(var b=null,c=null,d=null,e=null,f=0;fh&&(b=h),null===c?c=h:h>c&&(c=h),null===d?d=i:d>i&&(d=i),null===e?e=i:i>e&&(e=i)}return[b,d,c,e]}function h(a){for(var b,c=[],e=a.features.length-1;e>=0;e--)b=d(a.features[e].geometry),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function i(a){for(var b,c=[],e=a.geometries.length-1;e>=0;e--)b=d(a.geometries[e]),c.push([b[0],b[1]]),c.push([b[2],b[3]]);return g(c)}function k(a){var b=d(a);return{x:b[0],y:b[1],w:Math.abs(b[0]-b[2]),h:Math.abs(b[1]-b[3])}}function l(a){return a*Z}function m(a){return a*$}function n(a,b){for(var c=0;ca?-1:a>b?1:0}function u(a,b){return a[0]-b[0]>a[1]-b[1]?1:a[0]-b[0]w(b,c))&&(c=a[d])}return c}function y(a){if(0===a.length)return[];if(1===a.length)return a;for(var b=[a.sort(u)[0]],c=0;c=0&&1>=h&&i>=0&&1>=i)return!0}return!1}function C(a,b){for(var c=0;c=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=d}this.type="Point"}function N(b){if(b&&"MultiPoint"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=b}this.type="MultiPoint"}function O(b){if(b&&"LineString"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=b}this.type="LineString"}function P(b){if(b&&"MultiLineString"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=b}this.type="MultiLineString"}function Q(b){if(b&&"Polygon"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=b}this.type="Polygon"}function R(b){if(b&&"MultiPolygon"===b.type&&b.coordinates)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=b}this.type="MultiPolygon"}function S(a){if(a&&"Feature"===a.type)c(this,a);else{if(!(a&&a.type&&a.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=a}this.type="Feature"}function T(b){if(b&&"FeatureCollection"===b.type&&b.features)c(this,b);else{if(!a(b))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=b}this.type="FeatureCollection"}function U(b){if(b&&"GeometryCollection"===b.type&&b.geometries)c(this,b);else if(a(b))this.geometries=b;else{if(!b.coordinates||!b.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[b]}this.type="GeometryCollection"}function V(a,b,c){for(var d=p(a),e=c||64,f={type:"Polygon",coordinates:[[]]},g=1;e>=g;g++){var h=g*(360/e)*Math.PI/180;f.coordinates[0].push([d[0]+b*Math.cos(h),d[1]+b*Math.sin(h)])}return f.coordinates=I(f.coordinates),s(f)}function W(a,b,d){var e=d||64,f=b||250;if(!a||a.length<2||!f||!e)throw new Error("Terraformer: missing parameter for Terraformer.Circle");c(this,new S({type:"Feature",geometry:V(a,f,e),properties:{radius:f,center:a,steps:e}}))}var X={},Y=6378137,Z=57.29577951308232,$=.017453292519943,_={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}},ab={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}},bb=["length"];return L.prototype.toMercator=function(){return r(this)},L.prototype.toGeographic=function(){return s(this)},L.prototype.envelope=function(){return k(this)},L.prototype.bbox=function(){return d(this)},L.prototype.convexHull=function(){var a,b,c=[];if("Point"===this.type)return null;if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>=3))return null;c=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(a=0;a0))return null;for(a=0;a