I have my geoJson format like this:
statesData.features.push({
"type":"Feature",
"id":"AFG",
"properties":{
"name":"Afghanistan"
},
"geometry":{
"type":"Polygon",
"coordinates":[
[
[
61.210817,
35.650072
],
[
62.230651,
35.270664
],
[
62.984662,
35.404041
],
I am trying to read those coordinates and set them as
var coord = statesData.features[0].geometry.coordinates;
lalo = L.GeoJSON.coordsToLatLng(coord);
map.setView(lalo, 18);
coordsToLatLng( coords ) Function that will be used for converting GeoJSON coordinates to LatLng points (if not specified, coords will be assumed to be WGS84 — standard [longitude, latitude] values in degrees).
But I am getting this error in console
Uncaught Error: Invalid LatLng object: (undefined, 61.210817,35.650072,62.230651,35.270664,62.984662,35.404041...
UPDATE
The first answer is correct as it solves the issue above, however, it zooms the map to the first set of coordinates while what I am really trying to achieve is to be able to load the page with the map auto zoomed to a polygon (I only load one polygon).