Web Map Viewer
From Xojo Documentation
The Map Viewer uses Google Maps to display a map that is centered at a user-specified location. The location can be specified by its latitude and longitude coordinates or by a location, such as “Boston, MA”. You will typically also use the WebMapLocation and WebDeviceLocation classes with Map Viewer.
| As of June 2018, Google Maps requires an API Key. You will need to set the APIKey property to your API Key in order for WebMapViewer to display any maps. |
Commonly used events, properties and methods are listed below. For the complete list, refer to WebMapViewer in the Language Reference.
Events
- Called when the map has been re-centered.
- Called when the type of the map has changed.
Properties
- The Google Maps API key.
- Allow you to specify or check the latitude and longitude of the center of the displayed map. Call Update to relocate the map after making changes to these values.
- Used to specify the type of map that is displayed: Roadmap, Satellite, Hybrid, Terrain.
Methods
- Adds a WebMapLocation to the map. This displays a "pin" at the location.
- Centers the map on the passed WebMapLocation.
- Removes a WebMapLocation "pin" from the map.
- Centers the map after changes to Latitude and Longitude.
Web Map Location
Locations are created by using the WebMapLocation class.
You can use the Constructor to create a location based on a text address or by specific latitude and longitude as shown below.
Usage
Be sure to set your API key before attempting to display a map with code in its Open event:
This creates a location and displays it on a Map Viewer:
This displays a location entered by the user (in the LocationField TextField) on a Map Viewer:
Var location As New WebMapLocation(LocationField.Text)
MapViewer1.GoToLocation(location)
Catch e As NilObjectException
MsgBox("Invalid location.")
End Try
Example Projects
- Examples/Sample Applications/EddiesElectronics/Web/EEWeb
- Examples/Sample Applications/MapLocation
- Examples/Web/Controls/MapViewer/MapViewer
See Also
WebMapViewer, WebMapLocation classes; UserGuide:Web UI topic; Get Google Maps API Key
