GMaps_Documentation
GMaps_Documentation
1 / 13
1. Introduction
All our management applications have tables and management forms, for companies, clients, customers,
suppliers, employees, etc.
For each one of these entities, we usually keep record of a large amount of information, including its location
(address, city, etc). And with current resources in terms of geolocation, its generally useful to record the
geographic coordinates of that location (latitude and longitude), sometimes a great accuracy is needed.
Thus we can see the locations on the map, note the details at ground level, and calculate routes, particularly
between our location and the location of these entities, and vice versa.
This Control helps us to implement a global solution for all these tasks.
GMaps v1.1.12 – Google Maps/Routing/StreetView All-in-1 2014©Avelino Ferreira Pg. 2 / 13
The Control consists of a pair of files, both making use of the Google Maps API v3:
2. Usage
Control Source and Test projects are provided in Visual Studio 2008 version, however upgradable by later
versions.
The component DLL is located at …\GMaps_All-in-1\GMaps\bin\Release\GMaps.dll
Add it to your Toolbox, right-clicking the Toolbox area -> Choose Items… -> Browse -> select the DLL
In the Solution Explorer, select your Project, open My Project -> References -> Add… -> Browse -> select
GMaps
Drag the Control (GMaps) from the Toolbox to your Form. Give it a small size, it can be 0;0
Array(0) : ErrorCode – If an error occurs, the Control displays a message. Codes returned:
“0” – Its OK, no errors
“1” – Illegal type
“2” – Name <name> already exist as <type>
“3” – Coordinates <lat>/<lng> already exist as <type>
“4” – MyPlace/Place2 must be defined (when adding a WayPoint)
“5” – Type Latitude
“6” – Type Longitude
“7” – Type any Address element(s)
“8” – Cannot define more than 8 WayPoints
“9” – Incorrect data. Verify Latitude/Longitude
“10” – Incorrect data. Verify Address/City/Country/etc
“11” – Verify Internet connection
“12” – Exception Error message...
GMaps v1.1.12 – Google Maps/Routing/StreetView All-in-1 2014©Avelino Ferreira Pg. 3 / 13
Array(3) : Formatted Address – Returned by the Geocoder. Human-readable address of the location.
This address is generally composed of one or more address components.
Array(4) : Latitude - Returned by the Geocoder. A String containing a decimal number, representing
the Latitude of the location. Decimal Separator can be Dot or Comma, depending on Local Culture.
MyPlace and Place2 tags will be changed to any other previously redefined tags.
– Only allowed within previous operation. Returns to the Google Maps view, showing all
defined and adjusted points.
GMaps v1.1.12 – Google Maps/Routing/StreetView All-in-1 2014©Avelino Ferreira Pg. 5 / 13
– Only allowed within other views (Routes/StreetView). Shows a Map (Map or Satellite) with
all defined locations. Dragging Markers will update the Internal Location Table. Locations can be Added or
Updated through the Details panel , which is open in the next example:
/
In Google Maps view – – Opens the Details panel, where we can Define or Update
“MyPlace” / “Place2”, or Add / Remove WayPoints, and see all the related information returned by the
Geocoder.
In Route views – – Opens the Route options panel, where we can change some Route
parameters.
In StreetView view – – Opens the Point of view options panel, where we can change the
Camera position options.
– Closes the Control and returns to your Form, restoring its original size and location
(WindowState) and ControlBox.
Note: The Control is just Closed, not Disposed. So, its internal table of Locations is preserved, and all the
locations defined at your Form’s level will remain active if you call the Control again.
To clear the Control’s table of Locations, you can use the Clear Method, before calling the Control (see
LoadGMaps Method).
GMaps v1.1.12 – Google Maps/Routing/StreetView All-in-1 2014©Avelino Ferreira Pg. 8 / 13
5. Details panel
In Google Maps view, open this panel ( ) to Define or Update “MyPlace” / “Place2”, or Add /
Remove WayPoints, and see all the related information returned by the Geocoder.
Note: If you type Latitude/Longitude, a Reverse GeoCoding operation is performed, even if Address box(es) are
filled. If Latitude/Longitude are empty, a regular GeoCoding operation is performed.
– When pressed, shows Latitude and Longitude in the format Degreeso Minutes’ Seconds’’.
– Using the data typed in the input boxes, performs a GeoCoding operation, which, if
sucessful, fills the returned values boxes and Defines or Updates “MyPlace” location.
– Using the data typed in the input boxes, performs a GeoCoding operation, which, if
sucessful, fills the returned values boxes , Adds a new WayPoint location and updates the counter on the
right, which shows always the total number of loaded WayPoints.
Note: WayPoints cannot be Updated. Just Added or Deleted.
In StreetView view, open this panel ( ) to modify the Camera position options:
Camera heading – The camera heading (horizontal angle) in degrees. North is 0o, East is 90o, South is 180o,
West is 270o.
Camera pitch – The camera pitch (vertical angle), in degrees from the horizon (0o). Range from -90o (down)
to 90o (up) , although it is possible that not the full range is supported.
Note: In both cases, after sliding the cursor, when you release the mouse, the view is redrawn.
8. Control’s Properties
9. Control’s Methods/Functions
Clear Clears all Location information stored in the Control
Syntax: Clear()
Example:
GMaps1. Clear()
GeoCoding Given one or more text Address element(s), returns a String Array containing the
Geocoding Results – see 3.2. Geocoding Results
Syntax: GeoCoding(FullAddr As String) As Array
• FullAddr - The text Address element(s) must be “prepared” into a unique String – see PrepFullAddr
Function
Example – Calling the Method with constants (variables can also be specified):
Dim Res(5) As String
Res = GMaps1.GeoCoding(GMaps1.PrepFullAddr(New String() {“rua augusta, nº 2”, “lisboa”, “portugal”}))
result:
Res(0) : “0” - No errors occurred
Res(1) : “OK” - Status
Res(2) : “ROOFTOP” - Accuracy
Res(3) : “Rua Augusta 2, 1100-053 Lisbon, Portugal” - Formatted Address
Res(4) : “38.7085440” - Latitude
Res(5) : “-9.1367298” - Longitude
Remarks: See PrepFullAddr Function – Note that an input Array can also be used.
GeoReverse Given a Latitude and a Longitude, returns a String Array containing the Geocoding
Results – see 3.2. Geocoding Results
Syntax: GeoReverse(Latitude As String, Longitude As String) As Array
• Latitude - A String containing a numeric decimal value
• Longitude - A String containing a numeric decimal value
Example:
Dim Res(5) As String
Res = GMaps1.GeoReverse(“38.7085440”, “-9.1367298”)
result: Same as above (GeoCoding)
Note: Creating an Array to put the results, it is only necessary if you want to control, programmatically, the
occurrence of errors.
If there are no errors, the results of all operations of Defining or Adjusting can be controlled through the
GeoResults Event. So, the Method can be simply called this way:
Call GMaps1.LoadPlace(0, , “38.7085440”, “-9.1367298”)
Examples:
GMaps1. SetCenter(New String() {“Rua Fernão de Magalhães, nº 20-5ºDº+”, _
“8365-148”, “Armação de Pêra”, “Algarve”, “Portugal”}))
GMaps1. SetCenter("Eiffel Tower, Avenue Anatole France, Paris, France")
GMaps1. SetCenter( , “41.148087”, “-8.664355”)
GMaps1. SetCenter( , 41.148087, -8.664355)
Remarks: Initial Map CenterMap becomes visible only when you call the Control without any previous
Location definition
Str2DSCulture Given a Coordinate, replaces it Decimal Separator (Dot or Comma) with the
Current Culture Decimal Separator
Syntax: Str2DSCulture(Str As String) As String
• Str - A String containing a numeric decimal value
Example 1 – Assume Current Culture Decimal Separator is Comma:
GMaps1.Str2DSCulture(“-9.1367298”) result: “-9,1367298”
GMaps1.Str2DSCulture(“-9,1367298”) result: “-9,1367298”
Example 2 – Assume Current Culture Decimal Separator is Dot:
GMaps1.Str2DSCulture(“-9.1367298”) result: “-9.1367298”
GMaps1.Str2DSCulture(“-9,1367298”) result: “-9.1367298”
Remarks: No need to worry about this. Regardless of what you send, the Control always send Dot to the
Geocoder and returns Current Culture Decimal Separator
Str2DSDot Given a Coordinate, replaces it Decimal Separator (Dot or Comma) with Dot
Syntax: Str2DSDot(Str As String) As String
• Str - A String containing a numeric decimal value
Example:
GMaps1.Str2DSCulture(“-9.1367298”) result: “-9.1367298”
GMaps1.Str2DSCulture(“-9,1367298”) result: “-9.1367298”
Remarks: No need to worry about this. Regardless of what you send, the Control always send Dot to the
Goecoder and returns Current Culture Decimal Separator
10.Control’s Event
GeoResults Occurs whenever a Location is Defined or Adjusted (in Google Maps view), and the
Geocoding result Status is “OK”
Syntax: GeoResults(Adjusted As Boolean, Type As Byte, IndexWP As Integer, _
Address As String, Latitude As String, Longitude As String, _
Accuracy As String)
• Adjusted - False – A Location has been Defined
True – A Location has been Adjusted (by dragging the marker)
• Type - 1 – Location type is “MyPlace”
2 – Location type is “Place2”
0 – Location type is WayPoint
• IndexWP - If Location is a WayPoint, its Index ( 0 to 7 ). Otherwise, -1
• Address - The Formatted Address returned by the Geocoder
• Latitude - The Latitude returned by the Geocoder ()
• Longitude - The Longitude returned by the Geocoder ()
• Accuracy - Location's Accuracy returned by the Geocoder
() String containing a decimal number, Decimal Separator is Current Culture format
GMaps v1.1.12 – Google Maps/Routing/StreetView All-in-1 2014©Avelino Ferreira Pg. 13 / 13
Example:
Private Sub GMaps1_GeoResults(ByVal Adjusted As Boolean, ByVal Type As Byte, _
ByVal IndexWP As Integer, ByVal Address As String, ByVal Latitude As String, _
ByVal Longitude As String, ByVal Accuracy As String) Handles GMaps1.GeoResults
End Sub