2017-02-21 23 views
0

У меня есть рабочая функция, которая позволяет выбирать взаимодействие с указателем. Функция работы и выделения.
Еще одна вещь, которую я хотел бы получить, - показать свойство свойства для выбранной функции.
Я хотел бы получить на карте на этой конкретной функции не на новый HTML элемента или всплывающего окна
Работала из примера на http://openlayers.org/en/latest/examples/select-features.html
Любая помощь или идеи более что приветствуют :)

Функция отображения свойств OpenLayers на карте в разделе «Выбор взаимодействия»

roomsLayerEventMouserOver(layer) { 
    if(this.select){ 
     this.map.removeInteraction(this.select); 
    } 

    this.select = new ol.interaction.Select({ 
     condition: ol.events.condition.pointerMove, 
     layers: [ 
      layer 
     ], 
     style: this.getStyle('pink', 'red'), 
    }); 

    this.map.addInteraction(this.select); 
    this.select.on('select', (e) => { 
     let features = e.target.getFeatures(); 
     features.forEach((feature) => { 
      console.log(feature.getProperties().name); 
      // THIS IS PROBABLY THE PLACE I NEED SOMETHING 
     }); 

    }); 
} 

ответ

0

решение для:

roomsLayerEventMouserOver(layer) { 
    if(this.select){ 
     this.map.removeInteraction(this.select); 
    } 

    this.select = new ol.interaction.Select({ 
     condition: ol.events.condition.pointerMove, 
     layers: [ 
      layer 
     ], 
     style: (feature) => { return this.roomsSelectedFeatureStyle(feature); } 

    }); 

    this.map.addInteraction(this.select); 
} 


roomsSelectedFeatureStyle(feature) { 
    let roomNumber = feature.getProperties().name ? feature.getProperties().name : " "; 
    let style; 

    style = new ol.style.Style({ 
     text: new ol.style.Text({ 
      text: roomNumber 
     }), 
     stroke: new ol.style.Stroke({ 
      color: LAYER_ROOM_HIGHLIGTH_COLOR_BORDER, 
      width: 1 
     }), 
     fill: new ol.style.Fill({ 
      color: LAYER_ROOM_HIGHLIGTH_COLOR_FILL 
     }) 

    }); 

    return style; 
}