Search the PostGIS database to display the result in a table then highlight it on the OpenLayers map by...
Finding the error in an argument
Does Dispel Magic work on Tiny Hut?
How exploitable/balanced is this homebrew spell: Spell Permanency?
Why didn't Boeing produce its own regional jet?
Car headlights in a world without electricity
Can a virus destroy the BIOS of a modern computer?
Ambiguity in the definition of entropy
Bullying boss launched a smear campaign and made me unemployable
Can compressed videos be decoded back to their uncompresed original format?
How obscure is the use of 令 in 令和?
Finitely generated matrix groups whose eigenvalues are all algebraic
How do I exit BASH while loop using modulus operator?
How to stretch the corners of this image so that it looks like a perfect rectangle?
Where would I need my direct neural interface to be implanted?
Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?
GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?
What is required to make GPS signals available indoors?
Is it a bad idea to plug the other end of ESD strap to wall ground?
Was the old ablative pronoun "med" or "mēd"?
How to compactly explain secondary and tertiary characters without resorting to stereotypes?
What do you call someone who asks many questions?
Can I hook these wires up to find the connection to a dead outlet?
Could the museum Saturn V's be refitted for one more flight?
Was the Stack Exchange "Happy April Fools" page fitting with the '90's code?
Search the PostGIS database to display the result in a table then highlight it on the OpenLayers map by id
Select independent objects using GEOJson on OpenlayersOpenlayers: select a feature programmatically from GeoJsonLoading GEOJSON in Leaflet and separating attributesMarkerCluster don't work with geojson layer in leafletError loading geoJSON into map using OpenLayers v4.2.0Dynamically styling GeoJSON feature layer in OpenLayers 3?Get all the coordinates of a feature in OpenLayers 4Leaflet L.geoJSON from a js variable geojson object not showing on mapGet GeoJSON from a database by the AJAX method for OpenLayersSearches by area names in OpenLayers with request of AJAX in the PostGIS database
We did a search in the database according to certain search criteria, we displayed the results in a table by ajax request directly from the database my problem is because now I can not highlight on the map the item that was clicked in the results table ....
what has I done so far:
function wiev_search_results (id_teren) {
// alert (id_teren);
_myStroke = new ol.style.Stroke ({
color: 'yellow',
width: 4
});
_myFill = new ol.style.Fill ({
color: 'rgba (255,0,0,1.0)'
});
selected_polygon_style = new ol.style.Style ({
stroke: _myStroke,
fill: _myFill
});
console.log (feature);
var function = feature.forEachFeature (function (feature) {
if (feature.get ('id_teren') == id_teren) return feature;
});
if (feature) {
feature.setStyle (selected_polygon_style);
map.getView () fit (feature.getGeometry (), {duration: 2000}, {"maxZoom": 11});
}
}
GeoJSON:
{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}}]}
Error:
Uncaught TypeError: Cannot read property 'forEachFeature' of undefined
at wiev_search_results (admin.php:679)
at HTMLButtonElement.onclick (admin.php:1)
And on: console.log (feature);
is undefined and i do not know how to load here feauters from the map :(
You should search the objects already listed on the map by id_teren and id_cons and when you find an object that matches GeoJSON then color it in another color and zoom on that object.
Thank you in advance.
postgis openlayers geojson ajax
add a comment |
We did a search in the database according to certain search criteria, we displayed the results in a table by ajax request directly from the database my problem is because now I can not highlight on the map the item that was clicked in the results table ....
what has I done so far:
function wiev_search_results (id_teren) {
// alert (id_teren);
_myStroke = new ol.style.Stroke ({
color: 'yellow',
width: 4
});
_myFill = new ol.style.Fill ({
color: 'rgba (255,0,0,1.0)'
});
selected_polygon_style = new ol.style.Style ({
stroke: _myStroke,
fill: _myFill
});
console.log (feature);
var function = feature.forEachFeature (function (feature) {
if (feature.get ('id_teren') == id_teren) return feature;
});
if (feature) {
feature.setStyle (selected_polygon_style);
map.getView () fit (feature.getGeometry (), {duration: 2000}, {"maxZoom": 11});
}
}
GeoJSON:
{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}}]}
Error:
Uncaught TypeError: Cannot read property 'forEachFeature' of undefined
at wiev_search_results (admin.php:679)
at HTMLButtonElement.onclick (admin.php:1)
And on: console.log (feature);
is undefined and i do not know how to load here feauters from the map :(
You should search the objects already listed on the map by id_teren and id_cons and when you find an object that matches GeoJSON then color it in another color and zoom on that object.
Thank you in advance.
postgis openlayers geojson ajax
add a comment |
We did a search in the database according to certain search criteria, we displayed the results in a table by ajax request directly from the database my problem is because now I can not highlight on the map the item that was clicked in the results table ....
what has I done so far:
function wiev_search_results (id_teren) {
// alert (id_teren);
_myStroke = new ol.style.Stroke ({
color: 'yellow',
width: 4
});
_myFill = new ol.style.Fill ({
color: 'rgba (255,0,0,1.0)'
});
selected_polygon_style = new ol.style.Style ({
stroke: _myStroke,
fill: _myFill
});
console.log (feature);
var function = feature.forEachFeature (function (feature) {
if (feature.get ('id_teren') == id_teren) return feature;
});
if (feature) {
feature.setStyle (selected_polygon_style);
map.getView () fit (feature.getGeometry (), {duration: 2000}, {"maxZoom": 11});
}
}
GeoJSON:
{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}}]}
Error:
Uncaught TypeError: Cannot read property 'forEachFeature' of undefined
at wiev_search_results (admin.php:679)
at HTMLButtonElement.onclick (admin.php:1)
And on: console.log (feature);
is undefined and i do not know how to load here feauters from the map :(
You should search the objects already listed on the map by id_teren and id_cons and when you find an object that matches GeoJSON then color it in another color and zoom on that object.
Thank you in advance.
postgis openlayers geojson ajax
We did a search in the database according to certain search criteria, we displayed the results in a table by ajax request directly from the database my problem is because now I can not highlight on the map the item that was clicked in the results table ....
what has I done so far:
function wiev_search_results (id_teren) {
// alert (id_teren);
_myStroke = new ol.style.Stroke ({
color: 'yellow',
width: 4
});
_myFill = new ol.style.Fill ({
color: 'rgba (255,0,0,1.0)'
});
selected_polygon_style = new ol.style.Style ({
stroke: _myStroke,
fill: _myFill
});
console.log (feature);
var function = feature.forEachFeature (function (feature) {
if (feature.get ('id_teren') == id_teren) return feature;
});
if (feature) {
feature.setStyle (selected_polygon_style);
map.getView () fit (feature.getGeometry (), {duration: 2000}, {"maxZoom": 11});
}
}
GeoJSON:
{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.843,415221.025],[669031.588,415222.415],[669059.365,415154.448],[669064.041,415143.41],[669049.477,415135.059],[668987.876,415095.463],[668934.69,415061.12],[668904.2,415041.659],[668903.285,415044.048],[668934.224,415064.815],[668987.091,415097.897],[669048.669,415137.58],[669057.03,415142.935],[669054.159,415149.762],[669049.569,415160.172],[669045.995,415169.095],[669034.656,415197.283],[669031.864,415205.9],[669023.843,415221.025]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"2","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"010300000001000000130000002DB29DAFBF6A24419A999919D457194103560E2DCF6A24418FC2F5A8D9571941AE47E1BA066B24411283C0CAC9561941B6F3FD14106B24413D0AD7A39D561941105839F4F26A2441FA7E6A3C7C5619416F1283C0776A244108AC1CDADD55194114AE47610D6A2441AE47E17A5455194166666666D069244160E5D0A2065519412085EB91CE69244177E9263110551941C520B0720C6A2441295C8F4263551941508D972E766A2441002B8796E7551941022B8756F16A24411F85EB5186561941F6285C0F026B2441D5A370BD9B561941B1726851FC6A24415CBA490CB7561941CFF75323F36A24419CC420B0E0561941D8A370FDEB6A244114AE476104571941643BDF4FD56A244183C0CA21755719413F355EBACF6A24419A999999975719412DB29DAFBF6A24419A999919D4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[668906.809,415037.18],[668937.555,415056.882],[668994.661,415093.986],[669051.706,415130.5],[669059.946,415135.898],[669060.159,415135.449],[669051.997,415129.296],[668997.335,415093.406],[668938.441,415054.482],[668908.139,415035.654],[668906.809,415037.18]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"4","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000B0000007F3F359ED569244185EB51B8F4541941C3F5281C136A24410E022B87435519418C976E52856A2441E7FBA9F1D755194101D57869F76A2441000000006A5619415AC050E4076B2441800639977F561941AF726851086B2441F0A7C6CB7D561941B4C876FEF76A2441BE9F1A2F65561941B71E85AB8A6A2441C976BE9FD555194182C0CAE1146A2441736891ED395519410C022B47D86924410E2DB29DEE5419417F3F359ED569244185EB51B8F4541941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669023.722,415221.059],[669031.864,415205.9],[669034.656,415197.283],[669045.995,415169.095],[669049.569,415160.172],[669025.298,415144.634],[669019.118,415153.567],[669000.213,415207.177],[669023.722,415221.059]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"1","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"01030000000100000009000000E7FBA971BF6A2441FA7E6A3CD45719413F355EBACF6A24419A99999997571941643BDF4FD56A244183C0CA2175571941D8A370FDEB6A244114AE476104571941CFF75323F36A24419CC420B0E0561941BC749398C26A2441C34B3789A2561941FC7E6A3CB66A2441E3A59B44C656194104560E6D906A2441EE7C3FB59C571941E7FBA971BF6A2441FA7E6A3CD4571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669014.04,415175.438],[669021.134,415178.066],[669024.457,415169.094],[669017.363,415166.466],[669014.04,415175.438]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"0","id_cons":"1","cons":"C1","layer":"Building","wkb_geometry":"0103000000010000000500000049E17A14AC6A24416B1283C01D571941A9C69B44BA6A2441FB332343285719416DE7FBE9C06A244137894160045719410B02DBB9B26A2441AA67A1DDF956194149E17A14AC6A24416B1283C01D571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}},{"type":"Feature","id":0,"geometry":{"type":"Polygon","coordinates":[[[669047.108,415214.958],[669042.779,415213.194],[669065.641,415157.085],[669080.283,415119.838],[669083.267,415112.33],[669087.501,415114.297],[669087.927,415114.473],[669081.622,415129.71],[669069.529,415159.566],[669047.108,415214.958]]]},"crs":{"type":"EPSG","properties":{"code":"31700"}},"geometry_name":"wkb_geometry","properties":{"ogc_fid":0,"id_teren":"3","id_cons":"0","cons":"0","layer":"Green Area","wkb_geometry":"0103000000010000000A000000A8C64B37EE6A2441B6F3FDD4BB571941DE03E68EE56A24419815D5C6B4571941E9263148136B2441713D0A57D45619414260E590306B244108AC1C5A3F5619415839B488366B24411F85EB51215619416F1283003F6B24419CC4203029561941D0CCC8DA3F6B2441F73AC8E429561941B4C8763E336B2441713D0AD7665619418716D90E1B6B244106819543DE561941A8C64B37EE6A2441B6F3FDD4BB571941"}}]}
Error:
Uncaught TypeError: Cannot read property 'forEachFeature' of undefined
at wiev_search_results (admin.php:679)
at HTMLButtonElement.onclick (admin.php:1)
And on: console.log (feature);
is undefined and i do not know how to load here feauters from the map :(
You should search the objects already listed on the map by id_teren and id_cons and when you find an object that matches GeoJSON then color it in another color and zoom on that object.
Thank you in advance.
postgis openlayers geojson ajax
postgis openlayers geojson ajax
asked 5 mins ago
CoderCoder42CoderCoder42
324
324
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317594%2fsearch-the-postgis-database-to-display-the-result-in-a-table-then-highlight-it-o%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f317594%2fsearch-the-postgis-database-to-display-the-result-in-a-table-then-highlight-it-o%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown