I have several geoJSON files that contain city boundary information. Within the properties are the INTPTLAT and INTPTLON values for the center of the city area.’
Here is the structure of the file…
{ "type": "FeatureCollection",
"features": [ {
"type": "Feature",
"properties": {
"STATEFP": "48",
"PLACEFP": "20932",
"PLACENS": "02412441",
"GEOID": "4820932",
"NAME": "Dorchester",
"NAMELSAD": "Dorchester city",
"LSAD": "25",
"CLASSFP": "C1",
"PCICBSA": "N",
"PCINECTA": "N",
"MTFCC": "G4110",
"FUNCSTAT": "A",
"ALAND": 3390487,
"AWATER": 0,
"INTPTLAT": "+33.5312740",
"INTPTLON": "-096.6890979"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[ [-96.709237, 33.526649],
...
Here is the code used to get the geo file…
let twnGeo = 'assets/geojson/geopoly_twn_' + thisTown + '.json';
let streets = L.tileLayer(mbUrl, { attribution: mbAttr }),;
let twnBorder = new L.GeoJSON.AJAX(twnGeo, {style: { color: 'darkgray', weight: 2, fillColor: 'blue' },});
How can I extract the two values to define the center of the map? Is there a Leaflet method to do so or maybe a way to extract them from the JSON file?
jdadwilson