2022-11-02 14:44:06 +01:00
import { UIEventSource } from "../../Logic/UIEventSource"
import Loc from "../../Models/Loc"
import Minimap from "../Base/Minimap"
import ShowDataLayer from "../ShowDataLayer/ShowDataLayer"
import LayerConfig from "../../Models/ThemeConfig/LayerConfig"
2023-02-08 01:14:21 +01:00
import left_right_style_json from "../../assets/layers/left_right_style/left_right_style.json"
2022-11-02 14:44:06 +01:00
import StaticFeatureSource from "../../Logic/FeatureSource/Sources/StaticFeatureSource"
import { SpecialVisualization } from "../SpecialVisualization"
2022-10-28 04:33:05 +02:00
export class SidedMinimap implements SpecialVisualization {
funcName = "sided_minimap"
2022-11-02 14:44:06 +01:00
docs =
"A small map showing _only one side_ the selected feature. *This features requires to have linerenderings with offset* as only linerenderings with a postive or negative offset will be shown. Note: in most cases, this map will be automatically introduced"
2022-10-28 04:33:05 +02:00
args = [
{
doc : "The side to show, either `left` or `right`" ,
name : "side" ,
required : true ,
} ,
]
example = "`{sided_minimap(left)}`"
public constr ( state , tagSource , args ) {
const properties = tagSource . data
const locationSource = new UIEventSource < Loc > ( {
lat : Number ( properties . _lat ) ,
lon : Number ( properties . _lon ) ,
zoom : 18 ,
} )
const minimap = Minimap . createMiniMap ( {
background : state.backgroundLayer ,
location : locationSource ,
allowMoving : false ,
} )
const side = args [ 0 ]
const feature = state . allElements . ContainingFeatures . get ( tagSource . data . id )
2022-11-02 14:44:06 +01:00
const copy = { . . . feature }
2022-10-28 04:33:05 +02:00
copy . properties = {
id : side ,
}
new ShowDataLayer ( {
leafletMap : minimap [ "leafletMap" ] ,
zoomToFeatures : true ,
2022-11-02 14:44:06 +01:00
layerToShow : new LayerConfig ( left_right_style_json , "all_known_layers" , true ) ,
2022-10-28 04:33:05 +02:00
features : StaticFeatureSource.fromGeojson ( [ copy ] ) ,
state ,
} )
minimap . SetStyle ( "overflow: hidden; pointer-events: none;" )
return minimap
}
}