MCPcopy Create free account
hub / github.com/Maps4HTML/MapML.js / _createSelfOrStyleLink

Method _createSelfOrStyleLink

src/map-link.js:1012–1051  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1010 return isVisible;
1011 }
1012 _createSelfOrStyleLink() {
1013 let layerEl = this.getLayerEl();
1014 const changeStyle = function (e) {
1015 DomEvent.stop(e);
1016 layerEl.dispatchEvent(
1017 new CustomEvent('changestyle', {
1018 detail: {
1019 src: e.target.getAttribute('data-href')
1020 }
1021 })
1022 );
1023 };
1024
1025 let styleOption = document.createElement('div'),
1026 styleOptionInput = styleOption.appendChild(
1027 document.createElement('input')
1028 );
1029 styleOptionInput.setAttribute('type', 'radio');
1030 styleOptionInput.setAttribute('id', 'rad-' + stamp(styleOptionInput));
1031 styleOptionInput.setAttribute(
1032 'name',
1033 // grouping radio buttons based on parent layer's style <detail>
1034 'styles-' + stamp(styleOption)
1035 );
1036 styleOptionInput.setAttribute('value', this.getAttribute('title'));
1037 styleOptionInput.setAttribute(
1038 'data-href',
1039 new URL(this.href, this.getBase()).href
1040 );
1041 var styleOptionLabel = styleOption.appendChild(
1042 document.createElement('label')
1043 );
1044 styleOptionLabel.setAttribute('for', 'rad-' + stamp(styleOptionInput));
1045 styleOptionLabel.innerText = this.title;
1046 if (this.rel === 'style self' || this.rel === 'self style') {
1047 styleOptionInput.checked = true;
1048 }
1049 this._styleOption = styleOption;
1050 styleOptionInput.addEventListener('click', changeStyle.bind(this));
1051 }
1052 getLayerControlOption() {
1053 return this._styleOption;
1054 }

Callers 1

connectedCallbackMethod · 0.95

Calls 4

getLayerElMethod · 0.95
getBaseMethod · 0.95
setAttributeMethod · 0.80
getAttributeMethod · 0.80

Tested by

no test coverage detected