diff --git a/.crafter/screenshots/directions.png b/.crafter/screenshots/directions.png new file mode 100644 index 0000000..67a35b5 Binary files /dev/null and b/.crafter/screenshots/directions.png differ diff --git a/.crafter/screenshots/place.png b/.crafter/screenshots/place.png new file mode 100644 index 0000000..f02db6f Binary files /dev/null and b/.crafter/screenshots/place.png differ diff --git a/.crafter/screenshots/streetview.png b/.crafter/screenshots/streetview.png new file mode 100644 index 0000000..ef7c16e Binary files /dev/null and b/.crafter/screenshots/streetview.png differ diff --git a/authoring/content-types/component/googlemaps/config.xml b/authoring/content-types/component/googlemaps/config.xml new file mode 100644 index 0000000..51df44d --- /dev/null +++ b/authoring/content-types/component/googlemaps/config.xml @@ -0,0 +1,18 @@ + + +
/component/plugins/org/craftercms/plugin/google/maps/googlemaps
+ simple + NOT-USED-BY-SIMPLE-FORM-ENGINE + xml + false + false + false + + false + thumbnail.png + + + ^/site/website.* + + +
diff --git a/authoring/content-types/component/googlemaps/controller.groovy b/authoring/content-types/component/googlemaps/controller.groovy new file mode 100644 index 0000000..bb9b8c4 --- /dev/null +++ b/authoring/content-types/component/googlemaps/controller.groovy @@ -0,0 +1,13 @@ +import scripts.libs.CommonLifecycleApi; + +def contentLifecycleParams =[:]; +contentLifecycleParams.site = site; +contentLifecycleParams.path = path; +contentLifecycleParams.user = user; +contentLifecycleParams.contentType = contentType; +contentLifecycleParams.contentLifecycleOperation = contentLifecycleOperation; +contentLifecycleParams.contentLoader = contentLoader; +contentLifecycleParams.applicationContext = applicationContext; + +def controller = new CommonLifecycleApi(contentLifecycleParams); +controller.execute(); diff --git a/authoring/content-types/component/googlemaps/form-definition.xml b/authoring/content-types/component/googlemaps/form-definition.xml new file mode 100644 index 0000000..cc99deb --- /dev/null +++ b/authoring/content-types/component/googlemaps/form-definition.xml @@ -0,0 +1,1150 @@ +
+ Google Maps + + component + /component/plugins/org/craftercms/plugin/google/maps/googlemaps + undefined + false + + + display-template + + /templates/plugins/org/craftercms/plugin/google/maps/googlemaps.ftl + template + + + no-template-required + + + boolean + + + merge-strategy + + inherit-levels + string + + +
+ Map Properties + + true + + + locale-selector + localeCode + + Locale + + en + + + + datasource + + datasource:item + + + readonly + + boolean + + + + + required + + boolean + + + + + auto-filename + file-name + + Component ID + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + + + + + input + internal-name + + Internal Name + + + + + + size + 50 + int + + + maxlength + 50 + int + + + + + required + + boolean + + + + + input + width_s + + Width + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + height_s + + Height + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + dropdown + mapMode_s + + Map Mode + + place + + + + datasource + mapModes + datasource:item + + + emptyvalue + + boolean + + + readonly + + boolean + + + + + required + + boolean + + + + + label + message_s + + Message + + + + + + text + The following optional fields can be used depending on the selected Map Type + string + + + renderAsHTML + + boolean + + + + + + + dropdown + mapType_s + + Map Type + + + + + + datasource + mapTypes + datasource:item + + + emptyvalue + true + boolean + + + readonly + + boolean + + + + + required + + boolean + + + + + input + language_s + + Language + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + region_s + + Region + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + center_s + + Center + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + numeric-input + zoom_i + + Zoom + + + + + + size + 50 + int + + + maxValue + 21 + float + + + minValue + 0 + float + + + readonly + + boolean + + + tokenize + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + markerLocation_s + + Marker Location + + + Used in place & search modes + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + +
+
+ Directions + + false + + + input + origin_s + + Origin + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + destination_s + + Destination + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + waypoints_s + + Waypoints + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + dropdown + mode_s + + Mode + + + + + + datasource + modes + datasource:item + + + emptyvalue + + boolean + + + readonly + + boolean + + + + + required + + boolean + + + + + input + avoid_s + + Avoid + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + dropdown + units_s + + Units + + + + + + datasource + units + datasource:item + + + emptyvalue + + boolean + + + readonly + + boolean + + + + + required + + boolean + + + + +
+
+ Street View + + false + + + input + panoramaId_s + + Panorama Id + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + input + panoramaLocation_s + + Panorama Location + + + + + + size + 50 + int + + + maxlength + 50 + int + + + readonly + + boolean + + + tokenize + false + boolean + + + escapeContent + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + numeric-input + heading_i + + Heading + + + + + + size + 50 + int + + + maxValue + 360 + float + + + minValue + 180 + float + + + readonly + + boolean + + + tokenize + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + numeric-input + pitch_i + + Pitch + + + + + + size + 50 + int + + + maxValue + 90 + float + + + minValue + -90 + float + + + readonly + + boolean + + + tokenize + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + + numeric-input + filedOfView_i + + Filed Of View + + + + + + size + 50 + int + + + maxValue + 100 + float + + + minValue + 10 + float + + + readonly + + boolean + + + tokenize + false + boolean + + + + + required + + boolean + + + pattern + + string + + + + +
+
+ + key-value-list + mapModes + Map Modes + item + + + dataType + [{"value":"value","label":"","selected":false},{"value":"value_s","label":"String","selected":true},{"value":"value_i","label":"Integer","selected":false},{"value":"value_f","label":"Float","selected":false},{"value":"value_dt","label":"Date","selected":false},{"value":"value_html","label":"HTML","selected":false}] + dropdown + + + options + [{"key":"place","value":"Place"},{"key":"view","value":"View"},{"key":"directions","value":"Directions"},{"key":"streetview","value":"Street View"},{"key":"search","value":"Search"}] + keyValueMap + + + showkeys + + boolean + + + + + key-value-list + mapTypes + Map Types + item + + + dataType + [{"value":"value","label":"","selected":false},{"value":"value_s","label":"String","selected":true},{"value":"value_i","label":"Integer","selected":false},{"value":"value_f","label":"Float","selected":false},{"value":"value_dt","label":"Date","selected":false},{"value":"value_html","label":"HTML","selected":false}] + dropdown + + + options + [{"key":"roadmap","value":"Roadmap"},{"key":"satellite","value":"Satellite"}] + keyValueMap + + + showkeys + + boolean + + + + + key-value-list + modes + Modes + item + + + dataType + [{"value":"value","label":"","selected":false},{"value":"value_s","label":"String","selected":true},{"value":"value_i","label":"Integer","selected":false},{"value":"value_f","label":"Float","selected":false},{"value":"value_dt","label":"Date","selected":false},{"value":"value_html","label":"HTML","selected":false}] + dropdown + + + options + [{"key":"driving","value":"Driving"},{"key":"walking","value":"Walking"},{"key":"bicycling","value":"Bicycling"},{"key":"transit","value":"Transit"},{"key":"flying","value":"Flying"}] + keyValueMap + + + showkeys + + boolean + + + + + key-value-list + units + Units + item + + + dataType + [{"value":"value","label":"","selected":false},{"value":"value_s","label":"String","selected":true},{"value":"value_i","label":"Integer","selected":false},{"value":"value_f","label":"Float","selected":false},{"value":"value_dt","label":"Date","selected":false},{"value":"value_html","label":"HTML","selected":false}] + dropdown + + + options + [{"key":"metric","value":"Metric"},{"key":"imperial","value":"Imperial"}] + keyValueMap + + + showkeys + + boolean + + + + +
diff --git a/authoring/content-types/component/googlemaps/thumbnail.png b/authoring/content-types/component/googlemaps/thumbnail.png new file mode 100644 index 0000000..f02db6f Binary files /dev/null and b/authoring/content-types/component/googlemaps/thumbnail.png differ diff --git a/craftercms-plugin.yaml b/craftercms-plugin.yaml new file mode 100644 index 0000000..d4cb269 --- /dev/null +++ b/craftercms-plugin.yaml @@ -0,0 +1,71 @@ +# MIT License +# +# Copyright (c) 2018-2021 Crafter Software Corporation. All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# The version of the format for this file +descriptorVersion: 2 + +# Describe the plugin +plugin: + type: site + id: org.craftercms.plugin.google.maps + name: Google Maps + tags: + - web + - google + - maps + version: + major: 1 + minor: 0 + patch: 0 + description: A plugin to add Google Maps to a site + website: + name: Google Maps Plugin + url: https://github.com/craftercms/googlemaps-plugin + media: + screenshots: + - title: Place + description: Google Maps in place mode + url: https://raw.githubusercontent.com/craftercms/googlemaps-plugin/master/.crafter/screenshot/place.png + - title: Directions + description: Google Maps in directions mode + url: https://raw.githubusercontent.com/craftercms/googlemaps-plugin/master/.crafter/screenshot/directions.png + - title: Street View + description: Google Maps in Street View mode + url: https://raw.githubusercontent.com/craftercms/googlemaps-plugin/master/.crafter/screenshot/streetview.png + developer: + company: + name: Crafter Software + email: info@craftersoftware.com + url: https://craftersoftware.com + build: + id: c3d2a5444e6a24b5e0481d6ba87901d0b02716c8 + date: 2021-07-30T00:00:00Z + license: + name: MIT + url: https://opensource.org/licenses/MIT + crafterCmsVersions: + - major: 4 + minor: 0 + patch: 0 + crafterCmsEditions: + - community + - enterprise diff --git a/delivery/templates/googlemaps.ftl b/delivery/templates/googlemaps.ftl new file mode 100644 index 0000000..ec8c523 --- /dev/null +++ b/delivery/templates/googlemaps.ftl @@ -0,0 +1,85 @@ +<#import "/templates/system/common/crafter.ftl" as crafter /> + +<#assign apiKey = siteConfig.getString("plugins.googleMaps.apiKey")/> +<#assign params = []/> + +<#if contentModel.center_s?has_content> + <#assign params += ["center=" + contentModel.center_s]/> + + +<#if contentModel.zoom_i?has_content> + <#assign params += ["zoom=" + contentModel.zoom_i]/> + + +<#if contentModel.mapType_s?has_content> + <#assign params += ["maptype=" + contentModel.mapType_s]/> + + +<#if contentModel.language_s?has_content> + <#assign params += ["language=" + contentModel.language_s]/> + + +<#if contentModel.region_s?has_content> + <#assign params += ["region=" + contentModel.region_s]/> + + +<#switch contentModel.mapMode_s> + <#case "place"> + <#if contentModel.markerLocation_s?has_content> + <#assign params += ["q=" + contentModel.markerLocation_s]/> + + <#break> + <#case "directions"> + <#if contentModel.origin_s?has_content> + <#assign params += ["origin=" + contentModel.origin_s]/> + + <#if contentModel.destination_s?has_content> + <#assign params += ["destination=" + contentModel.destination_s]/> + + <#if contentModel.waypoints_s?has_content> + <#assign params += ["waypoints=" + contentModel.waypoints_s]/> + + <#if contentModel.mode_s?has_content> + <#assign params += ["mode=" + contentModel.mode_s]/> + + <#if contentModel.avoid_s?has_content> + <#assign params += ["avoid=" + contentModel.avoid_s]/> + + <#if contentModel.units_s?has_content> + <#assign params += ["units=" + contentModel.units_s]/> + + <#break> + <#case "streetview"> + <#if contentModel.panoramaId_s?has_content> + <#assign params += ["pano=" + contentModel.panoramaId_s]/> + + <#if contentModel.panoramaLocation_s?has_content> + <#assign params += ["location=" + contentModel.panoramaLocation_s]/> + + <#if contentModel.heading_i?has_content> + <#assign params += ["heading=" + contentModel.heading_i]/> + + <#if contentModel.pitch_i?has_content> + <#assign params += ["pitch=" + contentModel.pitch_i]/> + + <#if contentModel.fov_i?has_content> + <#assign params += ["fov=" + contentModel.fov_i]/> + + <#break> + <#case "search"> + <#if contentModel.markerLocation_s?has_content> + <#assign params += ["q=" + contentModel.markerLocation_s]/> + + <#break> + + +<#-- TODO: Handle page builder events to make sure the component is always editable --> +<@crafter.componentRootTag> + <@crafter.iframe + allowfullscreen="true" + width="${contentModel.width_s}" + height="${contentModel.height_s}" + frameborder="0" style="border:0" + src="https://www.google.com/maps/embed/v1/${contentModel.mapMode_s}?key=${apiKey}&${params?join('&')}" + /> + diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..7aa2434 --- /dev/null +++ b/readme.md @@ -0,0 +1,27 @@ +# Google Maps Plugin for Crafter CMS + +This is a highly configurable plugin to add Google Maps to your site. + +# Installation + +The plugin can be installed to your site from the Crafter CMS Marketplace + +# Setup + +After the plugin has been installed you need to setup your Google Maps API Key by adding the following snippet in +your site configuration: + +```xml + + + ... + + +``` + +# Usage + +Once the API Key is properly configured you can create any number of Google Maps components as needed. Each instance +of the component can be configured with any of the properties supported by Google Maps, for more information about +the options see the +[official docs](https://developers.google.com/maps/documentation/embed/embedding-map#choosing_map_modes).