From 8d2392e132ce5e090e18b6510b7bd3cf4a0650c9 Mon Sep 17 00:00:00 2001 From: Symbioquine Date: Tue, 1 Jun 2021 10:17:18 -0700 Subject: [PATCH] Remove core Google maps support **Why?** The strategy of loading the Google maps API via a script tag prior to initializing farmOS-map was one of the primary drivers of slow loading - even when Google maps wasn't used. See performance testing at https://github.com/farmOS/farmOS-map/pull/112 Although the strategy of splitting each behavior into its own chunk mostly mitigates any cost of including Google maps support in farmOS-map, it will be better for the maintainability of farmOS-map not to directly include Google maps support (RE: https://github.com/farmOS/farmOS-map/issues/99) and a contrib module for farmOS is a cleaner place for the integration to live anyway since such a contrib module could be fully optional and could include optimizations about how/when to load the Google maps API JS. --- README.md | 19 ---- examples/extended-behavior/static/index.html | 2 - .../simple-html-consumer/static/index.html | 2 - package-lock.json | 11 -- package.json | 1 - src/behavior/google.css | 4 - src/behavior/google.js | 107 ------------------ src/behavior/index.js | 1 - 8 files changed, 147 deletions(-) delete mode 100644 src/behavior/google.css delete mode 100644 src/behavior/google.js diff --git a/README.md b/README.md index 6a7bb4f..a01aba3 100644 --- a/README.md +++ b/README.md @@ -541,25 +541,6 @@ instance.addBehavior("edit").then(() => { ``` -### Google Maps - -To add Google Maps layers to a map, perform the following steps: - -1. Obtain a Google Maps JavaScript API key. For instructions, see: - https://farmos.org/hosting/apikeys/ -2. Add the following script tag to the page *before* any calls to - `farmOS.map.create()`, and replace `` with your API key: - -``` - -``` - -3. After calling `var instance = farmOS.map.create(target)`, call - `instance.addBehavior('google');`. - -It is important to set the `height` of the map element, otherwise the Google -Maps layers will not work. - ## Development `npm install` - Install JavaScript dependencies in `./node_modules` and create diff --git a/examples/extended-behavior/static/index.html b/examples/extended-behavior/static/index.html index a7e0714..8dd9ddf 100644 --- a/examples/extended-behavior/static/index.html +++ b/examples/extended-behavior/static/index.html @@ -21,7 +21,6 @@
- @@ -30,7 +29,6 @@ units: 'metric', } var myMap = farmOS.map.create("map", options); - myMap.addBehavior("google"); myMap.addBehavior("edit").then(() => { myMap.addBehavior("measure", { layer: myMap.edit.layer }); myMap.edit.wktOn("featurechange", console.log); diff --git a/examples/simple-html-consumer/static/index.html b/examples/simple-html-consumer/static/index.html index 12d7940..49307bb 100644 --- a/examples/simple-html-consumer/static/index.html +++ b/examples/simple-html-consumer/static/index.html @@ -21,7 +21,6 @@
-