diff --git a/app/helpers/gtt_map_helper.rb b/app/helpers/gtt_map_helper.rb index fb216248..fa58a91b 100644 --- a/app/helpers/gtt_map_helper.rb +++ b/app/helpers/gtt_map_helper.rb @@ -32,6 +32,8 @@ def map_tag(map: nil, layers: map&.layers, data[:popup] = popup if popup data[:upload] = upload data[:collapsed] = collapsed if collapsed + data[:geocoding] = true if Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true' + data[:target] = true if Setting.plugin_redmine_gtt['default_target_enabled'] == 'true' uid = "ol-" + rand(36**8).to_s(36) diff --git a/app/views/settings/gtt/_general.html.erb b/app/views/settings/gtt/_general.html.erb index d7466f33..540f4fd8 100644 --- a/app/views/settings/gtt/_general.html.erb +++ b/app/views/settings/gtt/_general.html.erb @@ -40,6 +40,7 @@ @settings['default_map_fit_maxzoom_level'], :size => 10) %>
++ <%= content_tag(:label, l(:label_default_target_enabled)) %> + <%= check_box_tag 'settings[default_target_enabled]', true, @settings[:default_target_enabled] %> +
+<%= content_tag(:label, l(:label_hide_map_for_invalid_geom)) %> <%= check_box_tag 'settings[hide_map_for_invalid_geom]', 1, Setting.plugin_redmine_gtt['hide_map_for_invalid_geom'] %> diff --git a/config/locales/de.yml b/config/locales/de.yml index f2cf4a6e..c637c784 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -43,6 +43,7 @@ de: label_enable_geojson_upload_on_issue_map: Aktivieren von GeoJSON-Upload auf der Themenkarte label_enable_geocoding_on_map: Geokodierung auf der Karte aktivieren + label_default_target_enabled: "Show target on map center" select_default_status_color: 'Auswahl der Standard-Statusfarbe:' select_default_map_settings: 'Standardmäßige Kartenvoreinstellungen festlegen:' select_edit_geometry_settings: 'Einstellungen für die Geometriebearbeitung:' diff --git a/config/locales/en.yml b/config/locales/en.yml index e8bd3c0a..e8bf8a96 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,6 +55,7 @@ en: label_editable_geometry_types_on_issue_map: "Editable geometry types on issue map" label_enable_geojson_upload_on_issue_map: "Enable GeoJSON upload on issue map" label_enable_geocoding_on_map: "Enable geocoding on map" + label_default_target_enabled: "Show target on map center" select_other_gtt_settings: "Other GTT settings" label_hide_map_for_invalid_geom: "Hide issue map for invalid geometry" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 49ce3610..3b11dc6d 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -53,6 +53,7 @@ ja: label_editable_geometry_types_on_issue_map: "チケット地図上で編集可能なジオメトリ種別" label_enable_geojson_upload_on_issue_map: "チケット地図上でGeoJSONアップロードを有効化" label_enable_geocoding_on_map: "地図上でジオコーディングを有効化" + label_default_target_enabled: "Show target on map center" select_other_gtt_settings: "GTTのその他の設定" label_hide_map_for_invalid_geom: "位置情報が登録されていない時に地図を隠す" diff --git a/init.rb b/init.rb index 086358f6..75beb000 100644 --- a/init.rb +++ b/init.rb @@ -30,6 +30,7 @@ 'default_map_maxzoom_level' => 19, 'default_map_fit_maxzoom_level' => 17, 'vector_minzoom_level' => 0, + 'default_target_enabled' => false, 'default_geocoder_options' => '{}', 'editable_geometry_types_on_issue_map' => ["Point"], 'enable_geojson_upload_on_issue_map' => false, diff --git a/src/components/gtt-client/init/controls.ts b/src/components/gtt-client/init/controls.ts index fb2c9a42..e9958cd8 100644 --- a/src/components/gtt-client/init/controls.ts +++ b/src/components/gtt-client/init/controls.ts @@ -1,8 +1,10 @@ import { FullScreen, Rotate } from 'ol/control'; +import { Style, RegularShape, Stroke } from 'ol/style'; import Bar from 'ol-ext/control/Bar'; import Button from 'ol-ext/control/Button'; import LayerPopup from 'ol-ext/control/LayerPopup'; import LayerSwitcher from 'ol-ext/control/LayerSwitcher'; +import Target from 'ol-ext/control/Target'; import Notification from 'ol-ext/control/Notification'; import { position } from 'ol-ext/control/control'; @@ -124,6 +126,34 @@ function addLayerSwitcherOrPopup(instance: any): void { } } +/** + * Adds target control to instance map. + * @param instance + */ +function addTargetControl(instance: any): void { + if (instance.contents.target) { + // Adjust the radius and stroke width for high DPI devices + const pixelRatio = window.devicePixelRatio || 1; + const adjustedRadius = 11 / pixelRatio; + const adjustedStrokeWidth = 3 / pixelRatio; + + instance.map.addControl(new Target({ + composite: 'overlay', + style: new Style({ + image: new RegularShape({ + points: 4, + radius: adjustedRadius, + radius2: 0, + stroke: new Stroke({ + color: 'rgba(220,26,26,0.7)', + width: adjustedStrokeWidth + }) + }) + }), + })); + } +} + /** * Adds notification control * @param {any} instance @@ -146,6 +176,7 @@ export function initControls(this: any): void { addFullScreenAndRotateControls(this); addMaximizeControl(this); handleMapRotation(this); + addTargetControl(this); if (this.contents.edit) { setControls.call(this, this.contents.edit.split(' '));