├── .babelrc ├── .eslintignore ├── .eslintrc.json ├── .github ├── CODEOWNERS ├── bundlewatch.config.json ├── dependabot.yml ├── sync-repo-settings.yaml └── workflows │ ├── bundlewatch.yml │ ├── codeql.yml │ ├── docs.yml │ ├── e2e.yml │ ├── package.yml │ ├── release.yml │ └── test.yml ├── .gitignore ├── .releaserc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── examples └── wmslayer.html ├── jest.config.js ├── package-lock.json ├── package.json ├── rollup.config.js ├── src ├── index.ts ├── wmsmaptype.test.ts └── wmsmaptype.ts ├── tsconfig.json └── typedoc.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/env", 5 | { 6 | "targets": { 7 | "browsers": "ie>=11, > 0.25%, not dead" 8 | }, 9 | "corejs": "3.6", 10 | "useBuiltIns": "usage" 11 | } 12 | ] 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | bazel-* 2 | coverage/ 3 | dist/ 4 | docs/ 5 | lib/ 6 | node_modules/ 7 | public/ -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["eslint:recommended", "plugin:prettier/recommended"], 3 | "parserOptions": { 4 | "ecmaVersion": 12, 5 | "sourceType": "module", 6 | "ecmaFeatures": { 7 | "jsx": true 8 | } 9 | }, 10 | "plugins": ["jest"], 11 | "rules": { 12 | "no-var": 2, 13 | "prefer-arrow-callback": 2 14 | }, 15 | "overrides": [ 16 | { 17 | "files": ["*.ts", "*.tsx"], 18 | "parser": "@typescript-eslint/parser", 19 | "plugins": ["@typescript-eslint"], 20 | "extends": ["plugin:@typescript-eslint/recommended"], 21 | "rules": { 22 | "@typescript-eslint/ban-ts-comment": 0, 23 | "@typescript-eslint/ban-types": 1, 24 | "@typescript-eslint/no-empty-function": 1, 25 | "@typescript-eslint/member-ordering": 1, 26 | "@typescript-eslint/explicit-member-accessibility": [ 27 | 1, 28 | { 29 | "accessibility": "explicit", 30 | "overrides": { 31 | "accessors": "explicit", 32 | "constructors": "no-public", 33 | "methods": "explicit", 34 | "properties": "explicit", 35 | "parameterProperties": "explicit" 36 | } 37 | } 38 | ] 39 | } 40 | } 41 | ], 42 | "env": { 43 | "browser": true, 44 | "node": true, 45 | "es6": true, 46 | "jest/globals": true 47 | }, 48 | "globals": { "google": "readonly" } 49 | } 50 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners 16 | 17 | .github/ @googlemaps/admin 18 | -------------------------------------------------------------------------------- /.github/bundlewatch.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | { 4 | "path": "dist/index.*.js" 5 | } 6 | ], 7 | "ci": { 8 | "trackBranches": ["main"], 9 | "repoBranchBase": "main" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version: 2 16 | updates: 17 | - package-ecosystem: "npm" 18 | directory: "/" 19 | schedule: 20 | interval: "weekly" 21 | -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # https://github.com/googleapis/repo-automation-bots/tree/main/packages/sync-repo-settings 16 | 17 | rebaseMergeAllowed: true 18 | squashMergeAllowed: true 19 | mergeCommitAllowed: false 20 | deleteBranchOnMerge: true 21 | branchProtectionRules: 22 | - pattern: main 23 | isAdminEnforced: false 24 | requiresStrictStatusChecks: false 25 | requiredStatusCheckContexts: 26 | - 'cla/google' 27 | - 'test' 28 | - 'snippet-bot check' 29 | - 'header-check' 30 | requiredApprovingReviewCount: 1 31 | requiresCodeOwnerReviews: true 32 | - pattern: master 33 | isAdminEnforced: false 34 | requiresStrictStatusChecks: false 35 | requiredStatusCheckContexts: 36 | - 'cla/google' 37 | - 'test' 38 | - 'snippet-bot check' 39 | - 'header-check' 40 | requiredApprovingReviewCount: 1 41 | requiresCodeOwnerReviews: true 42 | permissionRules: 43 | - team: admin 44 | permission: admin 45 | -------------------------------------------------------------------------------- /.github/workflows/bundlewatch.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Bundlewatch 16 | 17 | on: 18 | push: 19 | branches: 20 | - main 21 | pull_request: 22 | types: [synchronize, opened] 23 | 24 | jobs: 25 | bundlewatch: 26 | runs-on: ubuntu-latest 27 | env: 28 | CI_BRANCH_BASE: main 29 | steps: 30 | - uses: actions/checkout@v2 31 | - uses: jackyef/bundlewatch-gh-action@b9753bc9b3ea458ff21069eaf6206e01e046f0b5 32 | with: 33 | build-script: npm i 34 | bundlewatch-github-token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }} 35 | bundlewatch-config: .github/bundlewatch.config.json 36 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # For most projects, this workflow file will not need changing; you simply need 16 | # to commit it to your repository. 17 | # 18 | # You may wish to alter this file to override the set of languages analyzed, 19 | # or to provide custom queries or build logic. 20 | # 21 | # ******** NOTE ******** 22 | # We have attempted to detect the languages in your repository. Please check 23 | # the `language` matrix defined below to confirm you have the correct set of 24 | # supported CodeQL languages. 25 | # 26 | name: "CodeQL" 27 | 28 | on: 29 | push: 30 | branches: [main] 31 | pull_request: 32 | # The branches below must be a subset of the branches above 33 | branches: [main] 34 | schedule: 35 | - cron: "0 13 * * *" 36 | 37 | jobs: 38 | analyze: 39 | name: Analyze 40 | runs-on: ubuntu-latest 41 | permissions: 42 | actions: read 43 | contents: read 44 | security-events: write 45 | 46 | strategy: 47 | fail-fast: false 48 | matrix: 49 | language: ["javascript"] 50 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 51 | # Learn more: 52 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 53 | 54 | steps: 55 | - name: Checkout repository 56 | uses: actions/checkout@v2 57 | 58 | # Initializes the CodeQL tools for scanning. 59 | - name: Initialize CodeQL 60 | uses: github/codeql-action/init@v1 61 | with: 62 | languages: ${{ matrix.language }} 63 | # If you wish to specify custom queries, you can do so here or in a config file. 64 | # By default, queries listed here will override any specified in a config file. 65 | # Prefix the list here with "+" to use these queries and those in the config file. 66 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 67 | 68 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 69 | # If this step fails, then you should remove it and run the build manually (see below) 70 | - name: Autobuild 71 | uses: github/codeql-action/autobuild@v1 72 | 73 | # ℹ️ Command-line programs to run using the OS shell. 74 | # 📚 https://git.io/JvXDl 75 | 76 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 77 | # and modify them (or add more) to build your code if your project 78 | # uses a compiled language 79 | 80 | #- run: | 81 | # make bootstrap 82 | # make release 83 | 84 | - name: Perform CodeQL Analysis 85 | uses: github/codeql-action/analyze@v1 86 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Docs 16 | on: [push, pull_request] 17 | jobs: 18 | test: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v2 22 | - uses: actions/cache@v2 23 | with: 24 | path: ~/.npm 25 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 26 | restore-keys: | 27 | ${{ runner.os }}-node- 28 | - run: | 29 | npm i 30 | npm run docs 31 | - uses: peaceiris/actions-gh-pages@v3 32 | if: github.ref == 'refs/heads/main' 33 | with: 34 | github_token: ${{ secrets.GITHUB_TOKEN }} 35 | publish_dir: ./docs 36 | user_name: 'googlemaps-bot' 37 | user_email: 'googlemaps-bot@users.noreply.github.com' 38 | commit_message: ${{ github.event.head_commit.message }} 39 | -------------------------------------------------------------------------------- /.github/workflows/e2e.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: e2e 16 | on: 17 | push: 18 | schedule: 19 | - cron: "0 12 * * *" 20 | jobs: 21 | chrome: 22 | runs-on: ubuntu-latest 23 | services: 24 | hub: 25 | image: selenium/standalone-chrome 26 | volumes: 27 | - ${{ github.workspace }}:${{ github.workspace }} 28 | ports: 29 | - 4444:4444 30 | steps: 31 | - uses: actions/checkout@v2 32 | - run: npm i 33 | - run: npm run test:e2e 34 | firefox: 35 | runs-on: ubuntu-latest 36 | services: 37 | hub: 38 | image: selenium/standalone-firefox 39 | volumes: 40 | - ${{ github.workspace }}:${{ github.workspace }} 41 | ports: 42 | - 4444:4444 43 | steps: 44 | - uses: actions/checkout@v2 45 | - run: npm i 46 | - run: npm run test:e2e 47 | env: 48 | BROWSER: firefox 49 | -------------------------------------------------------------------------------- /.github/workflows/package.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Package 16 | on: 17 | - push 18 | - pull_request 19 | jobs: 20 | package: 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v2 24 | - run: npm i 25 | - uses: jpoehnelt/verify-npm-files-action@main 26 | with: 27 | keys: | 28 | types 29 | main 30 | module 31 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Release 16 | on: 17 | push: 18 | branches: 19 | - main 20 | concurrency: release 21 | jobs: 22 | build: 23 | runs-on: ubuntu-latest 24 | steps: 25 | - uses: actions/setup-node@v2 26 | with: 27 | node-version: '14' 28 | - name: Checkout 29 | uses: actions/checkout@v3 30 | with: 31 | token: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} 32 | - uses: actions/cache@v2 33 | with: 34 | path: ~/.npm 35 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 36 | restore-keys: | 37 | ${{ runner.os }}-node- 38 | - name: Test 39 | run: | 40 | npm i 41 | npm run lint 42 | npm test 43 | - name: Release 44 | uses: cycjimmy/semantic-release-action@v2 45 | with: 46 | extra_plugins: | 47 | @semantic-release/commit-analyzer 48 | semantic-release-interval 49 | @semantic-release/release-notes-generator 50 | @semantic-release/git 51 | @semantic-release/github 52 | @semantic-release/npm 53 | @googlemaps/semantic-release-config 54 | semantic-release-npm-deprecate 55 | env: 56 | GH_TOKEN: ${{ secrets.SYNCED_GITHUB_TOKEN_REPO }} 57 | NPM_TOKEN: ${{ secrets.NPM_WOMBAT_TOKEN }} 58 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | name: Test 16 | on: [push, pull_request] 17 | jobs: 18 | test: 19 | runs-on: ubuntu-latest 20 | steps: 21 | - uses: actions/checkout@v2 22 | - uses: actions/cache@v2 23 | with: 24 | path: ~/.npm 25 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 26 | restore-keys: | 27 | ${{ runner.os }}-node- 28 | - run: npm i 29 | - run: npm run lint 30 | - run: npm test 31 | - uses: codecov/codecov-action@v1 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist/ 3 | .npmrc 4 | **/docs 5 | 6 | # Logs 7 | logs 8 | *.log 9 | npm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # Diagnostic reports (https://nodejs.org/api/report.html) 15 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | *.lcov 29 | 30 | # nyc test coverage 31 | .nyc_output 32 | 33 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 34 | .grunt 35 | 36 | # Bower dependency directory (https://bower.io/) 37 | bower_components 38 | 39 | # node-waf configuration 40 | .lock-wscript 41 | 42 | # Compiled binary addons (https://nodejs.org/api/addons.html) 43 | build/Release 44 | 45 | # Dependency directories 46 | node_modules/ 47 | jspm_packages/ 48 | 49 | # TypeScript v1 declaration files 50 | typings/ 51 | 52 | # TypeScript cache 53 | *.tsbuildinfo 54 | 55 | # Optional npm cache directory 56 | .npm 57 | 58 | # Optional eslint cache 59 | .eslintcache 60 | 61 | # Microbundle cache 62 | .rpt2_cache/ 63 | .rts2_cache_cjs/ 64 | .rts2_cache_es/ 65 | .rts2_cache_umd/ 66 | 67 | # Optional REPL history 68 | .node_repl_history 69 | 70 | # Output of 'npm pack' 71 | *.tgz 72 | 73 | # Yarn Integrity file 74 | .yarn-integrity 75 | 76 | # dotenv environment variables file 77 | .env 78 | .env.test 79 | 80 | # parcel-bundler cache (https://parceljs.org/) 81 | .cache 82 | 83 | # next.js build output 84 | .next 85 | 86 | # nuxt.js build output 87 | .nuxt 88 | 89 | # gatsby files 90 | .cache/ 91 | public 92 | 93 | # vuepress build output 94 | .vuepress/dist 95 | 96 | # Serverless directories 97 | .serverless/ 98 | 99 | # FuseBox cache 100 | .fusebox/ 101 | 102 | # DynamoDB Local files 103 | .dynamodb/ 104 | 105 | # TernJS port file 106 | .tern-port 107 | 108 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 109 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 110 | 111 | # User-specific stuff 112 | .idea/**/workspace.xml 113 | .idea/**/tasks.xml 114 | .idea/**/usage.statistics.xml 115 | .idea/**/dictionaries 116 | .idea/**/shelf 117 | 118 | # Generated files 119 | .idea/**/contentModel.xml 120 | 121 | # Sensitive or high-churn files 122 | .idea/**/dataSources/ 123 | .idea/**/dataSources.ids 124 | .idea/**/dataSources.local.xml 125 | .idea/**/sqlDataSources.xml 126 | .idea/**/dynamic.xml 127 | .idea/**/uiDesigner.xml 128 | .idea/**/dbnavigator.xml 129 | 130 | # Gradle 131 | .idea/**/gradle.xml 132 | .idea/**/libraries 133 | 134 | # Gradle and Maven with auto-import 135 | # When using Gradle or Maven with auto-import, you should exclude module files, 136 | # since they will be recreated, and may cause churn. Uncomment if using 137 | # auto-import. 138 | # .idea/modules.xml 139 | # .idea/*.iml 140 | # .idea/modules 141 | # *.iml 142 | # *.ipr 143 | 144 | # CMake 145 | cmake-build-*/ 146 | 147 | # Mongo Explorer plugin 148 | .idea/**/mongoSettings.xml 149 | 150 | # File-based project format 151 | *.iws 152 | 153 | # IntelliJ 154 | out/ 155 | 156 | # mpeltonen/sbt-idea plugin 157 | .idea_modules/ 158 | 159 | # JIRA plugin 160 | atlassian-ide-plugin.xml 161 | 162 | # Cursive Clojure plugin 163 | .idea/replstate.xml 164 | 165 | # Crashlytics plugin (for Android Studio and IntelliJ) 166 | com_crashlytics_export_strings.xml 167 | crashlytics.properties 168 | crashlytics-build.properties 169 | fabric.properties 170 | 171 | # Editor-based Rest Client 172 | .idea/httpRequests 173 | 174 | # Android studio 3.1+ serialized cache file 175 | .idea/caches/build_file_checksums.ser 176 | 177 | # General 178 | .DS_Store 179 | .AppleDouble 180 | .LSOverride 181 | 182 | # Icon must end with two \r 183 | Icon 184 | 185 | 186 | # Thumbnails 187 | ._* 188 | 189 | # Files that might appear in the root of a volume 190 | .DocumentRevisions-V100 191 | .fseventsd 192 | .Spotlight-V100 193 | .TemporaryItems 194 | .Trashes 195 | .VolumeIcon.icns 196 | .com.apple.timemachine.donotpresent 197 | 198 | # Directories potentially created on remote AFP share 199 | .AppleDB 200 | .AppleDesktop 201 | Network Trash Folder 202 | Temporary Items 203 | .apdisk 204 | 205 | # Windows thumbnail cache files 206 | Thumbs.db 207 | Thumbs.db:encryptable 208 | ehthumbs.db 209 | ehthumbs_vista.db 210 | 211 | # Dump file 212 | *.stackdump 213 | 214 | # Folder config file 215 | [Dd]esktop.ini 216 | 217 | # Recycle Bin used on file shares 218 | $RECYCLE.BIN/ 219 | 220 | # Windows Installer files 221 | *.cab 222 | *.msi 223 | *.msix 224 | *.msm 225 | *.msp 226 | 227 | # Windows shortcuts 228 | *.lnk 229 | .vscode 230 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | extends: "@googlemaps/semantic-release-config" 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | 1. Submit an issue describing your proposed change to the repo in question. 4 | 1. The repo owner will respond to your issue promptly. 5 | 1. Fork the desired repo, develop and test your code changes. 6 | 1. Ensure that your code adheres to the existing style in the code to which 7 | you are contributing. 8 | 1. Ensure that your code has an appropriate set of tests which all pass. 9 | 1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. 10 | 1. Submit a pull request. 11 | 12 | ## Running the tests 13 | 14 | 1. Install dependencies: 15 | 16 | npm i 17 | 1. Run lint 18 | 19 | npm run lint 20 | npm run format # will fix some issues 21 | 22 | 1. Run the tests: 23 | 24 | # Run unit tests. 25 | npm test 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OGC Plugin for Google Maps 2 | 3 | [![npm](https://img.shields.io/npm/v/@googlemaps/ogc)](https://www.npmjs.com/package/@googlemaps/ogc) 4 | ![Build](https://github.com/googlemaps/js-ogc/workflows/Test/badge.svg) 5 | ![Release](https://github.com/googlemaps/js-ogc/workflows/Release/badge.svg) 6 | [![codecov](https://codecov.io/gh/googlemaps/js-ogc/branch/main/graph/badge.svg)](https://codecov.io/gh/googlemaps/js-ogc) 7 | ![GitHub contributors](https://img.shields.io/github/contributors/googlemaps/js-ogc?color=green) 8 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) 9 | [![](https://github.com/jpoehnelt/in-solidarity-bot/raw/main/static//badge-flat.png)](https://github.com/apps/in-solidarity) 10 | [![Discord](https://img.shields.io/discord/676948200904589322?color=6A7EC2&logo=discord&logoColor=ffffff)](https://discord.gg/jRteCzP) 11 | 12 | ## Description 13 | 14 | Add a WmsMapType to Google Maps. 15 | 16 | > **Note**: This package was previously located at https://github.com/googlemaps/v3-utility-library. 17 | 18 | ## NPM 19 | 20 | Available via NPM as the package `@googlemaps/ogc`. 21 | 22 | ``` shell 23 | npm i @googlemaps/ogc 24 | ``` 25 | 26 | ## Documentation 27 | 28 | The reference documentation can be found at this [link](https://googlemaps.github.io/js-ogc). 29 | 30 | ## Examples 31 | 32 | See the [WMS](https://googlemaps.github.io/js-ogc/examples/wmslayer.html) example in action. 33 | 34 | 35 | ``` javascript 36 | import { WmsMapType } from '@googlemaps/ogc'; 37 | 38 | map = new google.maps.Map(document.getElementById("map"), mapOptions); 39 | 40 | landCoverMapType = WmsMapType({ 41 | url: "https://www.mrlc.gov/geoserver/NLCD_Land_Cover/wms?", 42 | layers: "mrlc_display:NLCD_2016_Land_Cover_L48", 43 | name: "Land Cover", 44 | alt: "NLCD_2016_Land_Cover_L48", 45 | maxZoom: 18 46 | }); 47 | 48 | map.mapTypes.set("landcover", landCoverMapType); 49 | map.setMapTypeId("landcover"); 50 | 51 | // alternative as overlay 52 | map.overlayMapTypes.push(landCoverMapType); 53 | ``` 54 | 55 | ## Support 56 | 57 | This library is community supported. We're comfortable enough with the stability and features of 58 | the library that we want you to build real production applications on it. 59 | 60 | If you find a bug, or have a feature suggestion, please [log an issue][issues]. 61 | 62 | [issues]: https://github.com/googlemaps/js-ogc/issues 63 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Report a security issue 2 | 3 | To report a security issue, please use https://g.co/vulnz. We use 4 | https://g.co/vulnz for our intake, and do coordination and disclosure here on 5 | GitHub (including using GitHub Security Advisory). The Google Security Team will 6 | respond within 5 working days of your report on g.co/vulnz. 7 | 8 | To contact us about other bugs, please open an issue on GitHub. 9 | 10 | > **Note**: This file is synchronized from the https://github.com/googlemaps/.github repository. 11 | -------------------------------------------------------------------------------- /examples/wmslayer.html: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | 30 | 31 | 37 | 65 | 66 | 67 | 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module.exports = { 18 | transform: { 19 | "^.+\\.tsx?$": "ts-jest", 20 | }, 21 | collectCoverage: true, 22 | testPathIgnorePatterns: ["/dist/"], 23 | }; 24 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@googlemaps/ogc", 3 | "version": "1.0.33", 4 | "keywords": [ 5 | "google", 6 | "maps", 7 | "wms" 8 | ], 9 | "homepage": "https://github.com/googlemaps/js-ogc", 10 | "bugs": { 11 | "url": "https://github.com/googlemaps/js-ogc/issues" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/googlemaps/js-ogc.git" 16 | }, 17 | "license": "Apache-2.0", 18 | "author": "Justin Poehnelt", 19 | "main": "dist/index.umd.js", 20 | "unpkg": "dist/index.min.js", 21 | "module": "dist/index.esm.js", 22 | "types": "dist/index.d.ts", 23 | "files": [ 24 | "dist/*" 25 | ], 26 | "scripts": { 27 | "docs": "typedoc src/index.ts && cp -r dist docs/dist && cp -r examples docs/examples", 28 | "format": "eslint . --fix", 29 | "lint": "eslint .", 30 | "prepare": "rm -rf dist && rollup -c", 31 | "test": "jest src/*", 32 | "test:e2e": "jest --passWithNoTests e2e/*" 33 | }, 34 | "devDependencies": { 35 | "@babel/preset-env": "^7.21.4", 36 | "@babel/runtime-corejs3": "^7.21.0", 37 | "@googlemaps/jest-mocks": "^2.16.1", 38 | "@rollup/plugin-babel": "^6.0.3", 39 | "@rollup/plugin-commonjs": "^24.0.1", 40 | "@rollup/plugin-html": "^1.0.2", 41 | "@rollup/plugin-json": "^6.0.0", 42 | "@rollup/plugin-node-resolve": "^15.0.1", 43 | "@rollup/plugin-typescript": "^11.0.0", 44 | "@types/google.maps": "^3.49.1", 45 | "@types/jest": "^27.4.1", 46 | "@types/selenium-webdriver": "^4.1.13", 47 | "@typescript-eslint/eslint-plugin": ">=4.33.0", 48 | "@typescript-eslint/parser": ">=4.33.0", 49 | "chromedriver": "^111.0.0", 50 | "core-js": "^3.30.0", 51 | "eslint": "^7.32.0", 52 | "eslint-config-prettier": "^8.8.0", 53 | "eslint-plugin-jest": "^27.2.1", 54 | "eslint-plugin-prettier": "^4.2.1", 55 | "geckodriver": "^3.2.0", 56 | "jest": "^27.5.1", 57 | "prettier": "^2.8.7", 58 | "rollup": "^2.79.1", 59 | "rollup-plugin-terser": "^7.0.2", 60 | "selenium-webdriver": "^4.8.2", 61 | "ts-jest": "^27.1.4", 62 | "typedoc": "^0.23.28", 63 | "typescript": "^4.8.4" 64 | }, 65 | "publishConfig": { 66 | "access": "public", 67 | "registry": "https://wombat-dressing-room.appspot.com" 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import { babel } from "@rollup/plugin-babel"; 18 | import commonjs from "@rollup/plugin-commonjs"; 19 | import { terser } from "rollup-plugin-terser"; 20 | import typescript from "@rollup/plugin-typescript"; 21 | 22 | const babelOptions = { 23 | extensions: [".js", ".ts"], 24 | }; 25 | 26 | const terserOptions = { output: { comments: "" } }; 27 | 28 | export default [ 29 | { 30 | input: "src/index.ts", 31 | plugins: [ 32 | typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), 33 | commonjs(), 34 | babel(babelOptions), 35 | terser(terserOptions), 36 | ], 37 | output: [ 38 | { 39 | file: "dist/index.umd.js", 40 | format: "umd", 41 | sourcemap: false, 42 | name: "google.maps.plugins.ogc", 43 | }, 44 | { 45 | file: "dist/index.min.js", 46 | format: "iife", 47 | sourcemap: false, 48 | name: "google.maps.plugins.ogc", 49 | }, 50 | ], 51 | }, 52 | { 53 | input: "src/index.ts", 54 | plugins: [ 55 | typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), 56 | commonjs(), 57 | babel(babelOptions), 58 | terser(terserOptions), 59 | ], 60 | output: { 61 | file: "dist/index.dev.js", 62 | format: "iife", 63 | sourcemap: true, 64 | name: "google.maps.plugins.ogc", 65 | }, 66 | }, 67 | { 68 | input: "src/index.ts", 69 | plugins: [ 70 | typescript({ tsconfig: "./tsconfig.json", declarationDir: "./" }), 71 | ], 72 | output: { 73 | file: "dist/index.esm.js", 74 | format: "esm", 75 | }, 76 | }, 77 | ]; 78 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export { WmsMapType, WmsMapTypeOptions, xyzToBounds } from "./wmsmaptype"; 18 | -------------------------------------------------------------------------------- /src/wmsmaptype.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /// 18 | /// 19 | 20 | import { initialize } from "@googlemaps/jest-mocks"; 21 | import { 22 | xyzToBounds, 23 | EPSG_3857_EXTENT, 24 | WmsMapType, 25 | WmsMapTypeOptions, 26 | DEFAULT_WMS_PARAMS, 27 | } from "./wmsmaptype"; 28 | 29 | beforeEach(() => { 30 | initialize(); 31 | }); 32 | 33 | test("xyzToBounds is correct", () => { 34 | expect(xyzToBounds(0, 0, 0)).toEqual([ 35 | -EPSG_3857_EXTENT, 36 | -EPSG_3857_EXTENT, 37 | EPSG_3857_EXTENT, 38 | EPSG_3857_EXTENT, 39 | ]); 40 | }); 41 | 42 | test.each([ 43 | [ 44 | { 45 | url: "https://www.mrlc.gov/geoserver/NLCD_Land_Cover/wms", 46 | layers: "mrlc_display:NLCD_2016_Land_Cover_L48", 47 | styles: "mrlc:mrlc_NLCD_2016_Land_Cover_L48_20190424", 48 | bgcolor: "0xFFFFFF", 49 | version: "1.2.3", 50 | format: "image/jpeg", 51 | outline: true, 52 | transparent: true, 53 | name: "Land Cover", 54 | alt: "NLCD_2016_Land_Cover_L48", 55 | maxZoom: 18, 56 | minZoom: 0, 57 | opacity: 1.0, 58 | }, 59 | ], 60 | [ 61 | { 62 | url: "https://www.mrlc.gov/geoserver/NLCD_Land_Cover/wms?", 63 | layers: "mrlc_display:NLCD_2016_Land_Cover_L48", 64 | maxZoom: 18, 65 | }, 66 | ], 67 | ])("WmsMapType can be called with getTIleUrl", (options: WmsMapTypeOptions) => { 68 | WmsMapType(options); 69 | 70 | // need to get the mock in order of each 71 | const mock = (google.maps.ImageMapType as jest.Mock).mock; 72 | const tileUrl = mock.calls[mock.calls.length - 1][0].getTileUrl( 73 | new google.maps.Point(0, 0), 74 | 1, 75 | null 76 | ); 77 | 78 | const [base, queryString] = tileUrl.split("?"); 79 | 80 | expect(base).toEqual("https://www.mrlc.gov/geoserver/NLCD_Land_Cover/wms"); 81 | 82 | const params = new URLSearchParams(queryString); 83 | 84 | expect(params.get("layers")).toEqual(options["layers"]); 85 | expect(params.get("bgcolor")).toEqual(options["bgcolor"] || "0xFFFFFF"); 86 | expect(params.get("styles")).toEqual(options["styles"] || ""); 87 | expect(params.get("request")).toEqual(DEFAULT_WMS_PARAMS.request); 88 | expect(params.get("service")).toEqual(DEFAULT_WMS_PARAMS.service); 89 | expect(params.get("srs")).toEqual(DEFAULT_WMS_PARAMS.srs); 90 | expect(params.get("format")).toEqual(options["format"] || "image/png"); 91 | expect(params.get("outline")).toEqual(String(options["outline"] || false)); 92 | expect(params.get("version")).toEqual(options["version"] || "1.1.1"); 93 | expect(params.get("height")).toEqual("256"); 94 | expect(params.get("width")).toEqual("256"); 95 | }); 96 | -------------------------------------------------------------------------------- /src/wmsmaptype.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2019 Google LLC. All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * @ignore 19 | */ 20 | const DEFAULT_WMS_PARAMS = { 21 | request: "GetMap", 22 | service: "WMS", 23 | srs: "EPSG:3857", 24 | }; 25 | 26 | /** 27 | * @ignore 28 | */ 29 | const EPSG_3857_EXTENT = 20037508.34789244; 30 | 31 | /** 32 | * @ignore 33 | */ 34 | const ORIG_X = -EPSG_3857_EXTENT; // x starts from right 35 | 36 | /** 37 | * @ignore 38 | */ 39 | const ORIG_Y = EPSG_3857_EXTENT; // y starts from top 40 | 41 | /** 42 | * Convert xyz tile coordinates to mercator bounds. 43 | * 44 | * @param x 45 | * @param y 46 | * @param zoom 47 | * @returns {number[]} minx, miny, maxx, maxy 48 | */ 49 | function xyzToBounds(x: number, y: number, zoom: number): number[] { 50 | const tileSize = (EPSG_3857_EXTENT * 2) / Math.pow(2, zoom); 51 | const minx = ORIG_X + x * tileSize; 52 | const maxx = ORIG_X + (x + 1) * tileSize; 53 | const miny = ORIG_Y - (y + 1) * tileSize; 54 | const maxy = ORIG_Y - y * tileSize; 55 | return [minx, miny, maxx, maxy]; 56 | } 57 | 58 | interface WmsMapTypeOptions { 59 | url: string; 60 | layers: string; 61 | maxZoom: number; 62 | styles?: string; 63 | bgcolor?: string; 64 | version?: string; 65 | transparent?: boolean; 66 | format?: string; 67 | outline?: boolean; 68 | name?: string; 69 | alt?: string; 70 | minZoom?: number; 71 | opacity?: number; 72 | } 73 | 74 | /** 75 | * 76 | * @param {WmsMapTypeOptions} params 77 | */ 78 | const WmsMapType = function ({ 79 | url, 80 | layers, 81 | styles = "", 82 | bgcolor = "0xFFFFFF", 83 | version = "1.1.1", 84 | transparent = true, 85 | format = "image/png", 86 | outline = false, 87 | // google.maps.ImageMapTypeOptions interface 88 | name, 89 | alt, 90 | maxZoom, 91 | minZoom, 92 | opacity, 93 | }: WmsMapTypeOptions): google.maps.ImageMapType { 94 | // currently only support tileSize of 256 95 | const tileSize = new google.maps.Size(256, 256); 96 | 97 | const params = { 98 | layers, 99 | styles, 100 | version, 101 | transparent: String(transparent), 102 | bgcolor, 103 | format, 104 | outline: String(outline), 105 | width: String(tileSize.width), 106 | height: String(tileSize.height), 107 | ...DEFAULT_WMS_PARAMS, 108 | }; 109 | 110 | if (url.slice(-1) !== "?") { 111 | url += "?"; 112 | } 113 | 114 | const getTileUrl = function (coord: google.maps.Point, zoom: number): string { 115 | return ( 116 | url + 117 | new URLSearchParams({ 118 | bbox: xyzToBounds(coord.x, coord.y, zoom).join(","), 119 | ...params, 120 | }).toString() 121 | ); 122 | }; 123 | 124 | return new google.maps.ImageMapType({ 125 | getTileUrl, 126 | name, 127 | alt, 128 | opacity, 129 | maxZoom, 130 | minZoom, 131 | tileSize, 132 | }); 133 | }; 134 | 135 | export { 136 | EPSG_3857_EXTENT, 137 | DEFAULT_WMS_PARAMS, 138 | xyzToBounds, 139 | WmsMapType, 140 | WmsMapTypeOptions, 141 | }; 142 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "declaration": true, 4 | "declarationDir": "./dist", 5 | "noImplicitAny": true, 6 | "outDir": "./dist", 7 | "sourceMap": true, 8 | "esModuleInterop": true, 9 | "lib": ["DOM", "ESNext"], 10 | "target": "ES6", 11 | "moduleResolution": "node" 12 | }, 13 | "include": ["src/**/*"], 14 | "exclude": ["node_modules", "./dist"] 15 | } 16 | -------------------------------------------------------------------------------- /typedoc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | module.exports = { 18 | out: "docs", 19 | exclude: ["**/node_modules/**", "**/*.spec.ts", "**/*.test.ts"], 20 | name: "@googlemaps/ogc", 21 | excludePrivate: true, 22 | }; 23 | --------------------------------------------------------------------------------