I want remove old marker from TMapView (my name MapPiter) and set new one. Help please add C++ code.
Code: Select all
private: // User declarations
std::vector<TMapMarker *> FMarkers;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
void __fastcall ShowStateMarker(double x, double y, String s);
//cpp
void __fastcall TForm1::ShowStateMarker(double x, double y, String s)
{
//how conver in C++ ???
//I need remove old marker from TMapView and after call FMarkers.clear()
// var
// Marker: TMapMarker;
// begin
// for Marker in FMarkers do
// Marker.Remove;
// FMarkers.Clear;
// end;
//new marker
TMapCoordinate Position;
Position.Latitude = x;
Position.Longitude = y;
TMapMarkerDescriptor myMarker = TMapMarkerDescriptor::Create(Position, s);
myMarker.Draggable = false;
myMarker.Visible = true;
FMarkers.push_back(MapPiter->AddMarker(myMarker));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::ComboBoxStateChange(TObject *Sender)
{
if(ComboBoxState->ItemIndex != -1)
{
if(ComboBoxState->Selected->Text == L"Alabama")
{
MapPiter->Location = TMapCoordinate::Create(32.318231, -86.902298);
MapPiter->Zoom = 4;
ShowStateMarker(32.318231, -86.902298, L"Alabama");
}
else if(ComboBoxState->Selected->Text == L"Alaska")
{
MapPiter->Location = TMapCoordinate::Create(64.200841, -149.493673);
MapPiter->Zoom = 4;
ShowStateMarker(64.200841, -149.493673, L"Alaska");
}
}
}
Working with TMapView on iOS and Android