REST.SurfSpotFinder Sample (Delphi)
This sample shows how to integrate and use REST services in your application by using the Spitcast API in a Delphi application.
You can find the SurfSpotFinderApp sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and navigate to:
Object Pascal\Multi-Device Samples\Cloud\SurfSpot Finder
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
The application connects to the REST service from Spitcast to retrieve the list of Surf spots (sea locations for surfing). The application creates a main form that has two TMultiView components. Each TMultiView component contains a list of Surf spots and uses the TPanel to display the coordinates and county information, and the location coordinates on a map. Select a Surf spot from the SurfSpot finder list, and its location info is displayed. Click the plus icon to save the selected Surf spot in a text file and add it to the Favorite Spots list.
- Note: Public distribution of Spitcast API content must acknowledge Spitcast as the content source, and provide a link to spitcast.com. The Spitcast API is available for non-commercial use. Commercial use is possible by prior arrangement.
How to Use the Sample
- Navigate to Start | Programs | Embarcadero RAD Studio Sydney | Samples and open:
- Delphi: SurfSpotFinderApp.dproj
- Press F9 or choose Run > Run.
This project has one source file, SurfSpots.pas, that is, the main form that contains the REST Client and the TMultiView components.
TSurfSpotFinder, the form class, implements the main visual component of the application. It contains two TMultiView components and a TPanel with a TWebBrowser component for displaying the location on a map. It also contains the following components: TRESTClient, TRESTResponse, TRESTRequest, and TRESTResponseDataSetAdapter.
- For both TMultiView components, in the Object Inspector set the TargetControl property to Panel1.
- For the TMultiView1 component, in the Object Inspector set the MasterButton property to backbtn.
- For the TMultiView2 component, in the Object Inspector set the following properties:
- For the RESTClient1 component, in the Object Inspector set the BaseURL property to http://api.spitcast.com.
- For the RESTRequest1 component, in the Object Inspector set the following properties:
- For the RESTResponseDataSetAdapter component, in the Object Inspector set the following properties:
- Right-click the FDMemTable and select Fields Editor.
- Right-click the Fields Editor, select Add Fields and the fields county_name, latitude, longitude, spot_id, and spot_name.
- For the TMultiView1 component, visually bind the Surf Spots list from the Spitcats API call.
- The TMultiView2 component displays a list of the Favorites Surf Spots that is saved in a file.
- Mobile Tutorial: Using a MultiView Component to Display Alternate Views of Information (iOS and Android)
- DataSnap REST