WebMapViewer

From Xojo Documentation

(Redirected from Webmapviewer)

Class (inherits from WebControl)


New in 2011r2

Adds a Google map to the WE interface. It is initially centered at the position specified by Latitude, Longitude.

Events
CenterChanged Hidden MouseUp
Click KeyPressed Open
Close LostFocus Resized
ContextualMenuAction MouseDown Shown
DoubleClick MouseEnter TypeChanged
DropObject MouseExit ZoomChanged
GotFocus MouseMove
Properties
APIKey Left Page fa-lock-32.png
ContextualMenu LockBottom Parent fa-lock-32.png
ControlID fa-lock-32.png LockHorizontal Style
Cursor LockLeft Top
DragOverStyle LockRight VerticalCenter
Enabled LockTop Visible
Height LockVertical Width
HelpTag Longitude Zindex
HorizontalCenter MapType Zoom
Latitude Name fa-lock-32.png
Methods
AcceptPictureDrop AllowTextDrag RemoveLocation
AcceptRawDataDrop Close SetFocus
AcceptTextDrop ExecuteJavaScript ShowURL
AddLocation GoToLocation Update
AllowPictureDrag MsgBox
AllowRawDataDrag PresentContextualMenu

Notes

fa-exclamation-circle-32.png
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.

The WebMapViewer control is based on Google maps. As such, has the same strengths and limitations of Google Maps. At present, Google recommends the following browsers:

  • Microsoft Internet Explorer (IE) 9.0 and later (for Windows)1
  • Firefox 3.6 and later (for Windows, Mac, and Linux)
  • Safari 3.1 and later (for Mac and Windows)
  • Google Chrome (for Windows and Mac)

WebMapViewer has also been tested on iOS devices and on the Android emulator.

1As of November 2012, Google no longer supports Internet Explorer version 8 and earlier in their applications. If you want to use WebMapViewer in your projects, users will need to use another supported browser. You can detect the browser version in the WebSession.PrepareSession event like this:

If Session.Browser = Websession.BrowserType.InternetExplorer And CDbl(thisBrowserVersion) < 9 Then
// Show page displaying supported web browsers
End If

Google Maps API Key

As of June 2018, Google Maps requires an API Key. Visit the Google Maps docs for more information on usage:

Google Maps Platform User Guide

The MapViewer User Interface

When you add a WebMapViewer control to a WebPage, it comes with widgets to manipulate the zoom, the type, and the location. The zoom level is adjusted via the Slider control on the left and you can change the location by dragging with the hand (top-left). The type of map is changed by clicking the segmented control on the top-right corner. When you change the type (for example, from Map to Satellite), a check box appears below the Segmented Control to toggle that view type. If Map is selected, a Terrain checkbox appears to show or hide terrain features; if Satellite is selected, a checkbox appears to show or hide labels.

Sample Code

Create and display a location on the map:

Var location As New WebMapLocation("Fenway Park, Boston, MA")
MapViewer1.GoToLocation(location)

Display a location entered by the user (in the LocationField TextField) on the map:

Try
Var location As New WebMapLocation(LocationField.Text)
MapViewer1.GoToLocation(location)
Catch e As NilObjectException
MsgBox("Invalid location.")
End Try

See Also

WebDeviceLocation, WebMapLocation.