For some reason the polylines do not draw on the TTMSFNCMapBox either by using a gpx file or creating an array, I am able to render them in the OpenLayers version, but not on the MapBox. Is this a known issue? I a loading the data from a csv file in C++ builder.
ifstream readfile(OpenDialog1->FileName.c_str());
std::string thetext;
int lines = 0;
std::vector<std::unique_ptr<TTMSFNCMapsCoordinateRec>> coords;
std::vector<TTMSFNCMapsCoordinateRec> MyCoords;
while (getline(readfile, thetext) && exit == false)
{
if (lines > 0) {
try {
std::stringstream ssTmp(thetext.c_str());
int j = 0;
double lat = 0;
double lon = 0;
double alt = 0;
Memo1->Lines->Append(thetext.c_str());
while( ssTmp.good() ) {
std::string val;
getline( ssTmp, val, ',' );
//Log::d(ssTmp);
switch (j) {
case 0: lat = ::atof(val.c_str()); break;
case 1: lon = ::atof(val.c_str()); break;
case 2: alt = ::atof(val.c_str()); break;
default: break;
}
++j;
}
ssTmp.clear();
TTMSFNCMapsCoordinateRec coord;
coord.Latitude = lat;
coord.Longitude = lon;
coord.Elevation = alt;
coord.HasElevation = true;
coord.HasTimeStamp = false;
MyCoords.push_back(coord);
} catch (...) { }
}
++lines;
}
readfile.close();
TTMSFNCMapsCoordinateRecArray arr;
arr.Length = MyCoords.size();
for (int i = 0; i < MyCoords.size(); i++) {
arr[i] = MyCoords[i];
}
MyCoords.clear();
TTMSFNCMapsCoordinateRecArray arr2;
arr2.Length = 2;
TTMSFNCMapsCoordinateRec coord1;
coord1.Latitude = arr[0].Latitude;
coord1.Longitude = arr[0].Longitude;
coord1.Elevation = arr[0].Elevation;
coord1.HasElevation = true;
coord1.HasTimeStamp = false;
TTMSFNCMapsCoordinateRec coord2;
coord2.Latitude = arr[arr.Length-1].Latitude;
coord2.Longitude = arr[arr.Length-1].Longitude;
coord2.Elevation = arr[arr.Length-1].Elevation;
coord2.HasElevation = true;
coord2.HasTimeStamp = false;
arr2[0] = coord1;
arr2[1] = coord2;
TMSFNCMapBox2->BeginUpdate();
TTMSFNCMapsPolyline* polyline = TMSFNCMapBox2->AddPolyline(arr2);
polyline->StrokeWidth = 5;
polyline->StrokeColor = gcBlack; //TAlphaColorRec.Black; //gcRed;
polyline->StrokeOpacity = 1;
TMSFNCMapBox2->AddMarker(arr[0].Latitude, arr[0].Longitude);
TMSFNCMapBox2->AddMarker(arr[arr.Length-1].Latitude, arr[arr.Length-1].Longitude);
TMSFNCMapBox2->EndUpdate();
TMSFNCMapBox2->SetCenterCoordinate(arr[0].Latitude, arr[0].Longitude);
Thank you!
-Alessandro