I can't get the lat-lng array from a geoJson as expected (coordsToLatLngs)

1,686 views
Skip to first unread message

Rossana Guerra

unread,
Nov 10, 2014, 1:44:59 AM11/10/14
to leafl...@googlegroups.com
Hi, I need to get the latitude and longitude from a multilinestring geojson file in order to store them.  
I can get the array, but when I want them to convert to the lat, long format I got the error "is not a function"

This is the part of the code that isn't working.


function onEachFeature(feature, layer) {
 layer
.on({
 mouseover
: highlightFeature, //defined above -> it works
 mouseout
: resetHighlight,
    click
: zoomToFeature
   
})
    latlngBiciSendas
.push(feature.geometry.coordinates);        // Array
}

function resetHighlight(e) {
     geoBS
.resetStyle(e.target);
}


function loadBS()
{


    geoBS
= L.geoJson(bicisendas, {
       style
: style,
      onEachFeature
: onEachFeature
            
   
}).addTo(mapa);
 
    
L.geoJson.coordsToLatLngs(latlngBiciSendas,1,true);  <- this function is the problematic one.
 alert(latlngBiciSendas.length); The array is loaded correctly
 
};


In order to pass apply this array to an argument to some functions I need to "reverse" the array, i.e: put in the lat, long order.
I recall I am new to javascript and leaflet as well, I was trying and searching without luck. I don't know if I have syntax errors or the conceptual ones.


Error message: Uncaught TypeError: undefined is not a function 

I appreciate any help, thanks


Message has been deleted

Benedetto Dell'Ariccia

unread,
Nov 12, 2014, 9:25:41 AM11/12/14
to leafl...@googlegroups.com

Rossana Guerra

unread,
Nov 12, 2014, 2:28:28 PM11/12/14
to leafl...@googlegroups.com
Thanks Benedetto, I am sure that it isn't empty at the begining.
Secondly, I already had seen the link you posted, but it seemed it couldn't fit to my problem. 
My geojson is multinestring, so corrdinates[1] it didn't give what I expected.
As soon as I have time, I'll try to post my original code. 
Best!

--

---
You received this message because you are subscribed to a topic in the Google Groups "Leaflet" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leaflet-js/4MwERU8FXN4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leaflet-js+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages