-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
886 additions
and
790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
import { Id } from '../types/plugin'; | ||
|
||
/** | ||
* Floor level data | ||
* Floor level data. | ||
*/ | ||
export interface FloorLevel { | ||
modelId: Id; // id модели этажа или здания | ||
modelId: string; // id модели этажа или здания | ||
text: string; | ||
icon?: 'parking' | 'building' | string; | ||
} | ||
|
||
/** | ||
* Options for the method show | ||
* Options for the show method. | ||
*/ | ||
export interface ControlShowOptions { | ||
buildingModelId: Id; | ||
activeModelId: Id; | ||
buildingModelId: string; | ||
activeModelId: string; | ||
floorLevels?: FloorLevel[]; | ||
} | ||
|
||
/** | ||
* Event that emitted on button presses of the control | ||
* Event that emitted on button presses of the control. | ||
*/ | ||
export interface FloorChangeEvent { | ||
modelId: Id; // id модели этажа или здания | ||
modelId: string; // id модели этажа или здания | ||
} | ||
|
||
export interface ControlEventTable { | ||
/** | ||
* Emitted when floor's plan was changed | ||
* Emitted when floor's plan was changed. | ||
*/ | ||
floorchange: FloorChangeEvent; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
import type { PluginOptions } from './types/plugin'; | ||
|
||
export const defaultOptions: Required<PluginOptions> = { | ||
hoverHighlight: { | ||
hoverOptions: { | ||
color: '#ffffff', | ||
intencity: 0.0, | ||
}, | ||
modelsBaseUrl: '', | ||
modelsLoadStrategy: 'waitAll', | ||
poiConfig: { | ||
primary: { | ||
fontSize: 14, | ||
fontColor: '#000000', | ||
}, | ||
secondary: { | ||
fontSize: 14, | ||
fontColor: '#000000', | ||
}, | ||
}, | ||
floorsControl: { | ||
position: 'centerLeft', | ||
}, | ||
groundCoveringColor: '#F8F8EBCC', | ||
zIndex: 0, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import type { Map as MapGL, Label, LabelImage } from '@2gis/mapgl/types'; | ||
import type { BuildingState, LabelGroupOptions, PluginOptions } from './types/plugin'; | ||
import type { GltfPlugin } from './plugin'; | ||
// import { pluginEvents } from './constants'; | ||
// import { createLabelEvenData } from './utils/events'; | ||
|
||
const DEFAULT_IMAGE: LabelImage = { | ||
url: 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHJ4PSI0IiBmaWxsPSIjZWFlYWVhIi8+PHJlY3QgeD0iMSIgeT0iMSIgd2lkdGg9IjI2IiBoZWlnaHQ9IjI2IiByeD0iMyIgZmlsbD0id2hpdGUiLz48L3N2Zz4=', | ||
size: [38, 38], | ||
stretchX: [[4, 24]], | ||
stretchY: [[4, 24]], | ||
padding: [5, 10, 5, 10], | ||
}; | ||
|
||
export class LabelGroups { | ||
private labelsByGroupId: Map<string, Label[]> = new Map(); | ||
|
||
constructor( | ||
private map: MapGL, | ||
private plugin: GltfPlugin, | ||
private options: Required<PluginOptions>, | ||
) {} | ||
|
||
public add(groupOptions: LabelGroupOptions, state?: BuildingState) { | ||
const { id } = groupOptions; | ||
if (this.labelsByGroupId.has(id)) { | ||
console.error( | ||
`Poi group with id "${id}" already exists. Please use different identifiers for poi groups`, | ||
); | ||
return; | ||
} | ||
|
||
const { image, minZoom, maxZoom, fontColor: color, fontSize } = groupOptions; | ||
const labels = groupOptions.labels.map((labelOptions) => { | ||
const { coordinates, text, userData } = labelOptions; | ||
const label = new mapgl.Label(this.map, { | ||
coordinates, // + label.elevation ?? groupOptions.elevation | ||
text, | ||
userData, | ||
image: image === 'default' ? DEFAULT_IMAGE : image, | ||
minZoom, | ||
maxZoom, | ||
color, | ||
fontSize, | ||
relativeAnchor: [0.5, 1], | ||
zIndex: this.options.zIndex + 0.00001, // чтобы были выше моделей | ||
}); | ||
|
||
// pluginEvents.forEach((eventType) => { | ||
// label.on(eventType, (ev) => { | ||
// this.plugin.emit(eventType, createLabelEvenData(ev, labelOptions, state)); | ||
// }); | ||
// }); | ||
|
||
return label; | ||
}); | ||
|
||
this.labelsByGroupId.set(id, labels); | ||
} | ||
|
||
public remove(id: string) { | ||
const labels = this.labelsByGroupId.get(id); | ||
this.labelsByGroupId.delete(id); | ||
labels?.forEach((label) => label.destroy()); | ||
} | ||
|
||
public destroy() { | ||
this.labelsByGroupId.forEach((labels) => { | ||
labels.forEach((label) => label.destroy()); | ||
}); | ||
this.labelsByGroupId.clear(); | ||
} | ||
} |
Oops, something went wrong.