2017-10-11 17 views
2

マップ上でポリゴンを描きましたが、ポリゴンの境界線をクリックすると情報がポップアップします。 境界で選択を強制するソリューションはありますか?私が今やっていることopenlayers 3 - ポリゴン境界をクリック

  var featureContext = new ol.Feature({ 
       geometry: new ol.geom.Polygon([polyCoords]) 
      }) 

      featureContext.setStyle(
       new ol.style.Style({ 
        stroke: new ol.style.Stroke({ 
         color: context[cc].displayColor, 
         width: 3 
        }) 
       }) 
      ); 

      var layerContext = new ol.layer.Vector({ 
       source: new ol.source.Vector({ 
        features: [featureContext] 
       }) 
      }); 
      map.addLayer(layerContext); 

map.on('singleclick', function(evt) { 
     if (evt.dragging) { 
      return; 
     } 
     var feature = map.forEachFeatureAtPixel(map.getEventPixel(evt.originalEvent), function(feature) { 
      return feature; 
     }); 
     if (feature) { 
      popUp(feature); 
     } 
    }); 

しかし、これはポリゴンポリゴン(面積など)、ポップアップ情報のすべてを選択します。

ありがとうございました。

答えて

0

境界線を線(ポリゴンに加えて)として描画し、フィーチャが線である場合にのみ受け入れることはできますか?また、ポリゴンを指す線のプロパティにidを追加します。 いくつかのより良い方法が必要です...しかし、小さなポリゴンがいくつかある場合、これは問題ありません。

関連する問題