I am able to retrieve directions fine using the cloudmade api but I cant seem to add those coordinates to my map.
I've tried two different approaches
var myStyle = {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
};
var myLines = [{
"type": "LineString",
"coordinates": []
}];
myLines.coordinates = [[]];
for (var i = result.data.route_geometry.length - 1; i >= 0; i--) {
if(!isNaN(result.data.route_geometry[i][0]) && !isNaN(result.data.route_geometry[i][1])){
myLines.coordinates[i] = [result.data.route_geometry[i][0], result.data.route_geometry[i][1]];
}
};
L.geoJson(myLines, {style: myStyle}).addTo(window.map);
and
var geojsonFeature = {
"type": "Feature",
"properties": {
"name": "Coors Field",
"amenity": "Baseball Stadium",
"popupContent": "This is where the Rockies play!"
},
"geometry": {
"type": "Point",
"coordinates": []
}
};
for (var i = result.data.route_geometry.length - 1; i >= 0; i--) {
if(!isNaN(result.data.route_geometry[i][0]) && !isNaN(result.data.route_geometry[i][1])){
geojsonFeature.geometry.coordinates[i] = [result.data.route_geometry[i][0], result.data.route_geometry[i][1]];
}
};
L.geoJson(geojsonFeature).addTo(window.map);
I am able to add markers fine. My question is similar to this one Leaflet GeoJSON display and so I've tried reversing the coordinates like this
myLines.coordinates[i] = [result.data.route_geometry[i][0], result.data.route_geometry[i][1]];
but I still get nothing added to the map.
No errors in the console.