This example app demonstrates the following features:
- Shows how to do a search for POIs or text on an interactive movable and zoomable map, around a coordinate or within a bounding box, and centers the search result
The example has three buttons:
- to search POIs (points of interest) around a position (preset longitude, latitude - shown but not editable);
- to search free text around a position (preset longitude, latitude and search text - search text is editable);
- to search free text within a rectangular area (preset longitude, latitude for upper left and lower right corners, defining the bounding box within which to search, a lon,lat position within the box and search text - search text is editable);
The longitude, latitude coordinates of a point or bounding box are defined, and then the searchAroundPosition or search function is called to carry out the search asynchronously. The app waits for the search to complete, and then centers the map on the first result (at index 0) if there are any results.
- Create an instance of a
CTouchEventListenerto make the map interactive, enabling touch events such as pan and zoom - Create an instance of
MapViewproducing an OpenGL context using ImGUI, passing in the touch event listener, and a custom GUI function,getUiRender - The custom GUI function has a button to search for any POIs (points of interest) around a position, given as a
gem::Coordinatescontaining a longitude, latitude coordinate. The result is all POIs around that position, and are stored in agem::LandmarkList; the search is carried out usinggem::SearchService().searchAroundPosition()and aProgressListeneris used to be notified when the search results have been received - If the list of results has 1 or more items in it, that is, it is non-empty, the coordinates of the first result, at index 0, are obtained:
results[0].getCoordinates()and the map is centered on those coordinates:mapView->centerOnCoordinates()showing the results usingactivateHighlight() - The second button is to search specified text around a position. In addition to the
gem::Coordinates, thegem::LandmarkListto hold the results, and the progress listener to be notified when the search is complete, a plain text string is passed in as the search parameter:gem::SearchService().search(); Again, if the result list is non-empty, the coordinates of the first result, at index 0, are obtained, and the map is centered on those coordinates. - The third button is to search text within a rectangular area, or bounding box, specified by longitude, latitude coordinates for the upper left and the
lower right corners. The bounding box is specified using a
gem::RectangleGeographicArea, and an empty search preferences instance is also passed in usinggem::SearchPreferences(); a target position within the bounding box is also specified, as for the second button above. The search is carried out usinggem::SearchService().search()and the progress listener notifies when the results have been obtained. Again, if the result list is non-empty, the coordinates of the first result, at index 0, are obtained, and the map is centered on those coordinates.
