Skip to main content
added 42 characters in body
Source Link

I am trying to make a selection from a search result. I managed to make the selection on the map using the code below.

Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands. I would also like to zoom in on the selected land.

My code:

var extent = ol.extent.createEmpty ();

var selected_stile = new ol.style.Style({
    fill: new ol.style.Fill({color: makePattern()}),
    stroke: new ol.style.Stroke({
      color: [102,255,51], width: 3
    }),
  text: new ol.style.Text({
    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
    placement: 'center',
    fill: new ol.style.Fill({
      color: 'white', width: 23
    })
  })
});

imobile.getSource().forEachFeature(function(feature){
  feature.setId(feature.get('text'));
  
  var array = id_teren.split(",");
  for (i=0;i<array.length;i++){
    var data = "";
    if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
    if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
    if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
    if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
    if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }

     if(feature.get('text') == array[i]){
        console.log('GASITTTTTTTTTTTTTTTTT');
        var feature = imobile.getSource().getFeatureById(array[i]);
        
        selected_stile.getText().setText(data);
        feature.setStyle(selected_stile);
        ol.extent.extend(extent, feature.getGeometry().getExtent());
        
     }
  }   
});

I am trying to make a selection from a search result. I managed to make the selection on the map using the code below.

Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands. I would also like to zoom in on the selected land.

My code:

var selected_stile = new ol.style.Style({
    fill: new ol.style.Fill({color: makePattern()}),
    stroke: new ol.style.Stroke({
      color: [102,255,51], width: 3
    }),
  text: new ol.style.Text({
    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
    placement: 'center',
    fill: new ol.style.Fill({
      color: 'white', width: 23
    })
  })
});

imobile.getSource().forEachFeature(function(feature){
  feature.setId(feature.get('text'));
  
  var array = id_teren.split(",");
  for (i=0;i<array.length;i++){
    var data = "";
    if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
    if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
    if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
    if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
    if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }

     if(feature.get('text') == array[i]){
        console.log('GASITTTTTTTTTTTTTTTTT');
        var feature = imobile.getSource().getFeatureById(array[i]);
        
        selected_stile.getText().setText(data);
        feature.setStyle(selected_stile);
        ol.extent.extend(extent, feature.getGeometry().getExtent());
        
     }
  }   
});

I am trying to make a selection from a search result. I managed to make the selection on the map using the code below.

Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands. I would also like to zoom in on the selected land.

My code:

var extent = ol.extent.createEmpty ();

var selected_stile = new ol.style.Style({
    fill: new ol.style.Fill({color: makePattern()}),
    stroke: new ol.style.Stroke({
      color: [102,255,51], width: 3
    }),
  text: new ol.style.Text({
    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
    placement: 'center',
    fill: new ol.style.Fill({
      color: 'white', width: 23
    })
  })
});

imobile.getSource().forEachFeature(function(feature){
  feature.setId(feature.get('text'));
  
  var array = id_teren.split(",");
  for (i=0;i<array.length;i++){
    var data = "";
    if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
    if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
    if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
    if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
    if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }

     if(feature.get('text') == array[i]){
        console.log('GASITTTTTTTTTTTTTTTTT');
        var feature = imobile.getSource().getFeatureById(array[i]);
        
        selected_stile.getText().setText(data);
        feature.setStyle(selected_stile);
        ol.extent.extend(extent, feature.getGeometry().getExtent());
        
     }
  }   
});
Code display edit.
Source Link
TomazicM
  • 27k
  • 24
  • 31
  • 42

I am trying to make a selection from a search result .... I managed to make the selection on the map using the code below. Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands.

HeNow my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands. I would also like to zoom in on the selected land.

The CodeMy code:

var selected_stile = new ol.style.Style({
                                                                                    fill: new ol.style.Fill({color: makePattern()}),
                                                                                    stroke: new ol.style.Stroke({
                                                                                      color: [102,255,51], width: 3
                                                                                    }),
                                                                                  text: new ol.style.Text({
                                                                                    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
                                                                                    placement: 'center',
                                                                                    fill: new ol.style.Fill({
                                                                                      color: 'white', width: 23
                                                                                    })
                                                                                  })
                                                                                });
                                                                            
                                                                            
                                                                            
                                                                            imobile.getSource().forEachFeature(function(feature){
                                                                                feature.setId(feature.get('text'));
                                                                                
                                                                                var array = id_teren.split(",");
                                                                                for (i=0;i<array.length;i++){
                                                                                    
                                                                                       
                                                                                    
                                                                                        var data = "";
                                                                                        if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
                                                                                        if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
                                                                                        if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
                                                                                        if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
                                                                                        if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }
                                                                                    
                                                                                         if(feature.get('text') == array[i]){
                                                                                            console.log('GASITTTTTTTTTTTTTTTTT');
                                                                                            var feature = imobile.getSource().getFeatureById(array[i]);
                                                                                            
                                                                                            selected_stile.getText().setText(data);
                                                                                            feature.setStyle(selected_stile);
                                                                                            ol.extent.extend(extent, feature.getGeometry().getExtent());
                                                                                            
                                                                                         }
                                                                                         
                                                                                         
                                                                                         
                                                                                }
                                                                                
                                                                            });
   fill: new ol.style.Fill({color: makePattern()}),
    stroke: new ol.style.Stroke({
      color: [102,255,51], width: 3
    }),
  text: new ol.style.Text({
    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
    placement: 'center',
    fill: new ol.style.Fill({
      color: 'white', width: 23
    })
  })
});

imobile.getSource().forEachFeature(function(feature){
  feature.setId(feature.get('text'));
  
  var array = id_teren.split(",");
  for (i=0;i<array.length;i++){
    var data = "";
    if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
    if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
    if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
    if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
    if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }

     if(feature.get('text') == array[i]){
        console.log('GASITTTTTTTTTTTTTTTTT');
        var feature = imobile.getSource().getFeatureById(array[i]);
        
        selected_stile.getText().setText(data);
        feature.setStyle(selected_stile);
        ol.extent.extend(extent, feature.getGeometry().getExtent());
        
     }
  }   
});

I am trying to make a selection from a search result .... I managed to make the selection on the map using the code below. Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands.

He would also like to zoom in on the selected land

The Code:

var selected_stile = new ol.style.Style({
                                                                                    fill: new ol.style.Fill({color: makePattern()}),
                                                                                    stroke: new ol.style.Stroke({
                                                                                      color: [102,255,51], width: 3
                                                                                    }),
                                                                                  text: new ol.style.Text({
                                                                                    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
                                                                                    placement: 'center',
                                                                                    fill: new ol.style.Fill({
                                                                                      color: 'white', width: 23
                                                                                    })
                                                                                  })
                                                                                });
                                                                            
                                                                            
                                                                            
                                                                            imobile.getSource().forEachFeature(function(feature){
                                                                                feature.setId(feature.get('text'));
                                                                                
                                                                                var array = id_teren.split(",");
                                                                                for (i=0;i<array.length;i++){
                                                                                    
                                                                                       
                                                                                    
                                                                                        var data = "";
                                                                                        if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
                                                                                        if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
                                                                                        if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
                                                                                        if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
                                                                                        if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }
                                                                                    
                                                                                         if(feature.get('text') == array[i]){
                                                                                            console.log('GASITTTTTTTTTTTTTTTTT');
                                                                                            var feature = imobile.getSource().getFeatureById(array[i]);
                                                                                            
                                                                                            selected_stile.getText().setText(data);
                                                                                            feature.setStyle(selected_stile);
                                                                                            ol.extent.extend(extent, feature.getGeometry().getExtent());
                                                                                            
                                                                                         }
                                                                                         
                                                                                         
                                                                                         
                                                                                }
                                                                                
                                                                            });

I am trying to make a selection from a search result. I managed to make the selection on the map using the code below.

Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands. I would also like to zoom in on the selected land.

My code:

var selected_stile = new ol.style.Style({
    fill: new ol.style.Fill({color: makePattern()}),
    stroke: new ol.style.Stroke({
      color: [102,255,51], width: 3
    }),
  text: new ol.style.Text({
    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
    placement: 'center',
    fill: new ol.style.Fill({
      color: 'white', width: 23
    })
  })
});

imobile.getSource().forEachFeature(function(feature){
  feature.setId(feature.get('text'));
  
  var array = id_teren.split(",");
  for (i=0;i<array.length;i++){
    var data = "";
    if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
    if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
    if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
    if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
    if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }

     if(feature.get('text') == array[i]){
        console.log('GASITTTTTTTTTTTTTTTTT');
        var feature = imobile.getSource().getFeatureById(array[i]);
        
        selected_stile.getText().setText(data);
        feature.setStyle(selected_stile);
        ol.extent.extend(extent, feature.getGeometry().getExtent());
        
     }
  }   
});
Source Link

Zoom in for selected lands in OpenLayers

I am trying to make a selection from a search result .... I managed to make the selection on the map using the code below. Now my problem is that when I select one or more buildings with the same style, it does not automatically zoom in on the respective lands.

He would also like to zoom in on the selected land

The Code:

var selected_stile = new ol.style.Style({
                                                                                    fill: new ol.style.Fill({color: makePattern()}),
                                                                                    stroke: new ol.style.Stroke({
                                                                                      color: [102,255,51], width: 3
                                                                                    }),
                                                                                  text: new ol.style.Text({
                                                                                    font: 'bold 11px "Open Sans", "Arial Unicode MS", "sans-serif"',
                                                                                    placement: 'center',
                                                                                    fill: new ol.style.Fill({
                                                                                      color: 'white', width: 23
                                                                                    })
                                                                                  })
                                                                                });
                                                                            
                                                                            
                                                                            
                                                                            imobile.getSource().forEachFeature(function(feature){
                                                                                feature.setId(feature.get('text'));
                                                                                
                                                                                var array = id_teren.split(",");
                                                                                for (i=0;i<array.length;i++){
                                                                                    
                                                                                       
                                                                                    
                                                                                        var data = "";
                                                                                        if($('#etc_tarla').is(":checked")){ data = "T:"+feature.get('tarla')+"  "; }
                                                                                        if($('#etc_parcela').is(":checked")){ data = data+"P:"+feature.get('parcela')+"  "; }
                                                                                        if($('#etc_suprafata').is(":checked")){ data = data+"S:"+feature.get('suprafata')+"MP.  "; }
                                                                                        if($('#etc_proprietari').is(":checked")){ data = data+"P:"+feature.get('proprietari')+"  "; }
                                                                                        if($('#etc_eterra').is(":checked")){ data = data+"C.F.:"+feature.get('e_terra')+"  "; }
                                                                                    
                                                                                         if(feature.get('text') == array[i]){
                                                                                            console.log('GASITTTTTTTTTTTTTTTTT');
                                                                                            var feature = imobile.getSource().getFeatureById(array[i]);
                                                                                            
                                                                                            selected_stile.getText().setText(data);
                                                                                            feature.setStyle(selected_stile);
                                                                                            ol.extent.extend(extent, feature.getGeometry().getExtent());
                                                                                            
                                                                                         }
                                                                                         
                                                                                         
                                                                                         
                                                                                }
                                                                                
                                                                            });