Extended Nomads Objects -- Google Maps Interface
From PxPlus
A new Extended Control has been added to PxPlus to allow you to access external features, such as the Google Maps API, in a Nomads or iNomads environment. PxPlus Extended Controls are available through the Nomads COM interface, allowing you to select from a list of PVX Controls in addition to the list of Activex Controls when selecting a COM Control Name in the Nomads Designer. The remainder of the Nomads definition and processing is identical to that of a COM control. However, unlike most other COM controls, extended controls are also supported by iNomads.
The first extended control to be added to PxPlus is a Google Maps interface using the Google Maps API V3. Google Maps is a web mapping service application and technology provided by Google Inc., so access to the internet is a requirement to use the service. The PxPlus Google Maps extended control offers access to a wide range of features available in the Google Maps API,including map-related properties, methods and events, marker and info window processing, as well as geocoder functions. A built-in link on all maps also gives the user access to the Google Maps web page and additional functionality, such as directions requests.
| Nomads | iNomads |
|---|---|
Please visit the Google web site to learn the terms and conditions for including maps, geocoding and other content from Google in your webpages or applications. http://code.google.com/apis/maps/terms.html
Also visit the Google web site for more information on the Google Maps API V3: http://code.google.com/apis/maps/documentation/v3/
Contact PVXPlus Technologies to inquire about incorporating additional functionality into the PxPlus Google Map extended control.
To see a Flash presentation on using the Google Map extended control, go to http://www.pvxplus.com/swf/gmaps.htm
Contents |
Using the Google Map Extended Control
Use the Nomads Designer to add a Google Map to your application panel.
Select External Tools (COM control) from the Controls window and outline the location of the map on the panel.
In the Properties window, name the control; in our example we have called it MAP. Then click the COM Control Name button in the Display section and select PVX Controls from the pop-up menu. Select Google Maps Control from the list.
Click the Properties/Methods/Events button in the Display section of the Properties window.
Four properties are required when defining a map:
latitude - Latitude in degrees of the centerpoint of the map. Range is -90 to 90 degrees. longitude - Longitude in degrees of the centerpoint of the map. Range wraps from -180 to 180 degrees. mapTypeId - Type of map to be displayed. Options are hybrid, roadmap, satellite and terrain. zoom - Numeric zoom factor for the map. (Zero based).
Other properties are optional. Save the definition. This is sufficient to display the map on your panel, complete with map type and zoom controls, and full standard Google Map UI capability, including full mouse and keyboard control.
Now add some controls and logic to demonstrate some of the functionality available in Google Maps, such as adding and removing markers and info windows, and a demonstration of geocoding which translates human-readable addresses into latitude/longitude locations and vice-versa.
Add three multilines, address, latitude and longitude, as well as fonted-text prompts to accompany them. Set the Numeric attribute for the latitude and longitude multilines.
You will need more than standard precision to handle latitude and longitude values, so set Precision to 6 in the Display section of the panel header Properties window.
Add a Geocode_Address button, a Geocode_Location button, and a Close button to exit the panel. Set the On Change logic for the Close button to End.
This example shows just a few of the properties, methods and events available to the Google Maps Extended Control. Full details are described in the rest of this document. Also visit the Google Maps web site for additional information. http://code.google.com/apis/maps/documentation/v3/
Map Properties
Following are the map-related properties supported by the PxPlus Google Maps Extended Control. The properties are set when the map is created, and are read-only (except for the value property). Their values can be changed subsequently by using the corresponding set method.
| Property | Description |
|---|---|
| backgroundColor$ | Colour used for the background of the map. This colour is visible when tiles have not yet been loaded and the user pans. Format is hex #HHHHHH (e.g. #FF00FF) or a standard HTML colour name (e.g. yellow). |
| clickLatitude | Latitude in degrees at the location where a Click or RightClick event occurs on a map. |
| clickLongitude, | Longitude in degrees at the location where a Click or RightClick event occurs on a map. |
| clickMarker | Numeric identifier of the marker involved in a MarkerClick event. |
| col | Horizontal screen position of map in columns. |
| cols | Width of map in column units. |
| containerObject | Object id of browser object in which the map is displayed. (NOMADS only) |
| ctlName$ | Control type. Value is 'Extended'. |
| disableDefaultUI | Enables/disables all default user interface features, such as double click zoom, draggability, scrollwheel, etc. UI features may be overridden individually. Boolean. Default is false (enabled). |
| draggable | Enables/disables the ability to drag the map. Boolean. Default is true (enabled). |
| geocodeLatitude | Longitude in degrees at the location of the last invoked #Geocoder Method. |
| geocodeLongitude | Longitude in degrees at the location of the last invoked #Geocoder Method. |
| geocodeStatus$ | Status of the last invoked #Geocoder Method. |
| infoWindowCount | Number of info windows currently displayed. |
| keyboardShortcuts | Enables/disables keyboard control of the map. Boolean. Default is enabled (true). |
| latitude | Latitude in degrees of the map center. Range is clamped between -90 degrees and 90 degrees. |
| longitude | Longitude in degrees of the map center. Longitude is wrapped between -180 degrees and 180 degrees. |
| mapTypeControl | Enabled/disabled state of the map type control. Boolean. Default is enabled. |
| mapTypeControlStyle$ | Display option for the map type control. Options are 'default', 'dropdown_menu' and 'horizontal_bar'. |
| mapTypeId$ | Map type. Options are 'hybrid', 'roadmap', 'satellite' and 'terrain'. Required. |
| markerCount | Number of markers currently displayed. |
| name$ | Control name. |
| navigationControl | Enabled/disabled state of the navigation control. Boolean. Default is enabled. |
| navigationControlStyle$ | Display option for the navigation control. Options are 'default', 'android', 'small' and 'zoom_pan'. The default setting varies depending on map size and other factors. |
| noClear | If true, the contents of the map are not cleared. |
| pvxError$ | Error value. |
| pvxEvents$ | List of available events. |
| region$ | Unicode region subtag identifier. Can be used to override the standard location bias. (Optional) |
| scaleControl | Enabled/disabled state of the scale control. |
| scaleControlStyle$ | Display option for the scale control. Option is 'default'. |
| scrollWheel | Enables/disables scrollwheel zooming on the map. Boolean. Default is true (enabled). |
| sensor | Indicates whether the application is using a sensor (such as a GPS locator) to determine the location. Boolean. Default is false. Required. |
| value$ |
String of value pairs that contain all the data required to define the current map. Format is a list of assignment expressions separated by $00$. e.g. "sensor=0"+$00$+ "region$="""""+$00$+ "latitude=43.77"+$00$+ "longitude=-79.4525"+$00$+ "mapTypeID$=""hybrid""+$00$+ "zoom=14"+$00$+ [etc.] An example (not showing the $00$ separators) is shown on the right. The value$ property is a read/write property. When set, the map is redisplayed using the new value settings. |
| zoom | Initial zoom level for the map. Required. |
Map Events
Following are the events supported by the PxPlus Google Maps Extended Control.
| Event | Description |
|---|---|
| click | This event is fired when the user clicks on the map. The location of the last click can be found in the clickLatitude and clickLongitude properties. |
| rightClick | This event is fired when the user right-clicks on the map. The location of the last right-click can be found in the clickLatitude and clickLongitude properties. |
| markerClick | This event is fired when the user clicks on a marker. The marker identifier can be found in the clickMarker property. |
Map Methods
Following are the map-related methods supported by the PxPlus Google Maps Extended Control.
| Method | Description |
|---|---|
| fitBounds(S,W,N,E) | Sets the map to fit the given boundaries, where:
S - Southernmost latitude in degrees. W - Westernmost longitude in degrees. N - Northernmost latitude in degrees. E - Easternmost longitude in degrees. |
| getBounds$() | Returns a string containing the southernmost latitude, westernmost longitude, northernmost latitude and easternmost longitude in degrees, separated by commas. |
| getCenter$() | Returns the latitude and longitude in degrees of the centerpoint of the map. |
| getLatitude() | Returns the latitude in degrees of the centerpoint of the map. |
| getLongitude() | Returns the longitude in degrees of the centerpoint of the map. |
| getMapTypeId$() | Returns the type of map. Types are 'roadmap', 'satellite', 'hybrid' and 'terrain'. |
| getZoom() | Returns the current zoom setting. |
| initialize(name$,properties$, methods$,events$,eventCount) | Initializes properties, methods and events used by Nomads and iNomads. |
| panBy(cols,lines) | Changes the center of the map by the given number of columns and rows. Use positive values to pan to the right or down, and negative values to pan left or up. |
| panTo(latitude,longitude) | Changes the center of the map to the given latitude and longitude. |
| setCenter(latitude,longitude) | Changes the center of the map to the given latitude and longitude. |
| setMapTypeId(type$) | Sets the map type. Options are 'roadmap', 'satellite', 'hybrid' and 'terrain'. |
| setOptions(options$) | Sets map attributes specified in options$, a list of SEP-separated values pairs, consisting of attribute names and values in the format attribute=value.
Boolean values can be specifed using 0 and -1, or true and false. Null string values can be specified by leaving the value blank. E.g. "mapTypeID=terrain"+SEP+"draggable=false"+SEP+"zoom=4"+sep+"backgroundColor="+SEP |
| setZoom(n) | Sets the zoom level of the map. |
Marker Methods
Following are the marker methods supported by the PxPlus Google Maps Extended Control.
| Method | Description |
|---|---|
| addMarker(latitude,longitude [,title$,icon$,zIndex]) | Add a marker at the specified latitude and longitude.
Returns a numeric identifier to be used when referencing the marker in marker-related methods. The following arguments are optional: Title$ - Title is displayed in the marker tip. Icon$ - URL to image to be used for the marker. zIndex - Markers are displayed in order of their zindex; those with higher values are displayed in front of those with lower values. By default, markers with lower latitudes take precedence. |
| clearMarkers() | Removes all markers from the map. |
| getMarkerClickable(markerid) | Returns a boolean value indicating whether the specified marker is clickable. |
| getMarkerDraggable(markerid) | Returns a boolean value indicating whether the specified marker is draggable. |
| getMarkerFlat(markerid) | Returns a boolean value indicating whether the specified marker is flat (i.e. has no shadow). |
| getMarkerIcon$(markerid) | Returns the URL of the image for the specified marker. |
| getMarkerLatitude(markerid) | Returns the latitude in degrees of the specified marker. |
| getMarkerLongitude(markerid) | Returns the longitude in degrees of the specified marker. |
| getMarkerPosition$(markerid) | Returns a comma-separated string containing the latitude and longitude in degrees of the specified marker. |
| getMarkerTitle$(markerid) | Returns a string containing the title of the specified marker. |
| getMarkerVisible(markerid) | Returns a boolean value indicating whether the specified marker is visible. |
| getMarkerZIndex(markerid) | Returns the zIndex of the specifed marker. (See addMarker() for an explanation of zIndex.) |
| removeMarker(markerid) | Remove the specified marker. |
| setMarkerClickable(markerid,flag) | Sets whether or not the specified marker is clickable. Flag is boolean. |
| setMarkerDraggable(markerid,flag) | Sets whether or not the specified marker is draggable. Flag is boolean. |
| setMarkerFlat(markerid,flag) | Sets whether or not the specified marker is flat. Flag is boolean.
Note - If an icon is specified, the marker will be flat. |
| setMarkerIcon(markerid, icon$) | Sets the image to be used as the specified marker.
Icon$ - URL to the image. e.g. setMarkerIcon(markerid,"file:///c:/work/images/star.bmp") setMarkerIcon(markerid,"http://www.mydomain.com/home/images/mymarker.jpg") |
| setMarkerOptions(markerid,options$) | Sets marker attributes specified in options$ for the given marker. Options$ contains a list of SEP-separated values pairs, consisting of attribute names and values in the format attribute=value.
Boolean values can be specifed using 0 and -1, or true and false. Null string values can be specified by leaving the value blank. E.g. "draggable=true"+SEP+"title="+SEP+"+"icon=file:///work/images/star.bmp"+SEP |
| setMarkerPosition(markerid, latitude,longitude) | Move the specified marker to the given latitude and longitude. |
| setMarkerTitle(markerid,title$) | Sets the title of the specified marker. The title is displayed as the marker tip. |
| setMarkerVisible(markerid, flag) | Sets whether or not the specified marker is visible. Flag is boolean. |
| setMarkerZIndex(markerid,n) | Sets the zIndex of the specified marker. (See addMarker() for an explanation of zIndex.) |
Info Window Methods
An info window is a text bubble that can be displayed at a given location or connected to a marker. Following are the info window methods supported by the PxPlus Google Maps Extended Control.
| Method | Description |
|---|---|
| closeInfoWindow(iw_id) | Closes the info window with the specified identifier. |
| getInfoWindowContent$(iw_id) | Returns the text content of the info window with the specified identifier. |
| getInfoWindowLatitude(iw_id) | Returns the latitude in degrees of the info window with the specified identifier. |
| getInfoWindowLongitude(iw_id) | Returns the longitude in degrees of the info window with the specified identifier. |
| getInfoWindowPosition$(iw_id) | Returns a comma-separated string specifying the latitude and longitude in degrees of the info window with the specified identifier. |
| setInfoWindowContent(iw_id,content$) | Sets the content to be displayed in the specified info window. This can be a plain-text string or a string containing HTML. |
| setInfoWindowPosition(iw_id,lat,lng) | Moves the info window with the specified identifier to the indicated latitude and longitude. |
| showInfoWindow(lat, lng, content$ [,zIndex, disableAutoPan])
showInfoWindow(markerid, contents$ [,zIndex, disableAutoPan]) | Displays an info window with the given content at the specified latitude and longitude, or at the marker with the specified identifier. Returns a numeric identifier to be used when referencing the info window in info window-related methods.
Optional arguments include: zIndex - Info windows are displayed in order of their zindex, with higher values displaying in front of info windows with lower values. By default, info windows with lower latitudes take precedence. disableAutoPan - Disables the default auto-pan behaviour that makes the info window fully visible when it is initially displayed. |
Geocoder Method
Geocoding is the process of converting human-readable addresses (like "42 Scenic Drive, Yourtown, ON") into geographic coordinates (like latitude 44.123456 and longitude -79.654321), which you can use to place markers or position the map. The process of translating a location on a map to a human-readable address is known as reverse geocoding. Both processes are available using the two formats of the geocode$( ) method.
| Method | Description |
|---|---|
| geocode$(address$) | Given a human-readable address, returns a string containing the corresponding latitude and longitude in degrees, separated by a comma. The resulting latitude and longitude are also loaded into the geocodeLatitude and geocodeLongitude properties. |
| geocode$(lat,lng,level) | Given a latitude, longitude and level, returns the corresponding human-readable address. The level indicates how specific or general the resulting address will be, with 0 being the most specific. (Note that the geocoder will attempt to find the closest addressable location, within reason. If none exists, a null string is returned.) |
