To send information to the map, utilize this code:
function join(){
$.when(
$.getJSON('bairro.json'),
$.getJSON('convertJson.php')
).done(function(responseGeojson, responseData) {
var data = responseData[0]
var geojson = responseGeojson[0]
// Create a hash table for easy reference
var dataHash = {}
console.log('==data==');
console.log(data);
data.forEach(function(item) {
if(item.cod)
dataHash[item.cod] = item.cod;
if(item.nome)
dataHash[item.nome] = item.nome;
if(item.local)
dataHash[item.local] = item.local;
})
// Assign values from hash table to geojson properties
geojson.features.forEach(function(item) {
console.log('-->' + dataHash[item.properties.nome]);
item.properties.Codigo = +dataHash[item.properties.cod] || null
item.properties.Nome = +dataHash[item.properties.nome] || null
item.properties.Local = +dataHash[item.properties.local] || null
})
})
}
However, there are issues with undefined values and no image displaying on the map.
Here is an example of how Geojson looks:
{"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "NOME": "local1", "REGIAO_ADM": "value1", "CODBAIRRO": "13"}, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 694555.509827277157456, 7483079.800010865554214 ], [ 694554.849827276892029, 7483077.34010686352849 ], [ 694551.869923274731264, 7483076.470026861876249 ],...}
{ "type": "Feature", "properties": { "NOME": "local2", "REGIAO_ADM": "value2", "CODBAIRRO": "13"}, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 694555.509827277157456, 7483079.800010865554214 ], [ 694554.849827276892029, 7483077.34010686352849 ], [ 694551.869923274731264, 7483076.470026861876249 ],...}
{ "type": "Feature", "properties": { "NOME": "local3", "REGIAO_ADM": "value3", "CODBAIRRO": "13"}, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 694555.509827277157456, 7483079.800010865554214 ], [ 694554.849827276892029, 7483077.34010686352849 ], [ 694551.869923274731264, 7483076.470026861876249 ],...}
This illustrates how the JSON file is structured:
[{ "cod": "13", "local": "local1", "nome": "value1" }, { "cod": "98", "local": "local2", "nome": "value2" }, { "cod": "97", "local": "local3", "nome": "value3" }]
If you have any insight into what might be going wrong or can provide assistance, please let me know!