Pman's Lab

Welcome to my lab.

A demonstration of what I work on during spare time. Visit the my Lab page to see what I have done so far.

Documentation for GMouseWheelControl

Welcome to the documentation of GMouseWheelControl, which you might find helpful if you are planning to add this control to your Google Map meshup. First of all, you will need to have a map created using Google Map API. You can visit Google Map API documentation page to know how to create your own map, if you haven't done so already. This documentation assumes that you are familiar with Google Map API and as such only relevant coding examples will be shown to use GMouseWheelControl. See Complete Reference of GMouseWheelControl.

Adding GMouseWheelControl to map

Adding GMouseWheelControl to your map is no different than adding any other controls to the map. You would use addControl() method of GMap2 class to add GMouseWheelControl to your map. So, the following example will add the control to your map allowing the user to take full advantage of GMouseWheelControl.

var map = new GMap2(document.getElementById("myMap"));
map.setCenter(new GLatLng(43.65872874896846, -79.37926769256592), 3);
var gmwControl = new GMouseWheelControl() ;
map.addControl(gmwControl) ;

The above will add the control to the default location. To control the location where it is added, you can refer to the control positioning documentation. For the rest of the documentation in this page, it will be assumed that the control was added like it was shown above. Click on the link below to see an example on how to add GMouseWheelControl to Googl Map.

View example (addingGmwControl.html)

Control Appearance

Once GMouseWheelControl is added to your map, there are a number of actions that you can perform in terms of how you would like the control to appear on your map. You can choose to display the control buttons on the map or hide it. If the control buttons are not displayed on the map, the user will be able to perform only the currently selected operation since the buttons to choose different options are not available. Likewise, you can also show or hide the button texts or icons from the control buttons. Below is an example of how to disable text labels from buttons.

var map = new GMap2(document.getElementById("myMap"));
map.setCenter(new GLatLng(43.65872874896846, -79.37926769256592), 3);
var gmwControl = new GMouseWheelControl() ;
map.addControl(gmwControl) ;
gmwControl.disableButtonText() ;

The above example will add the contol to the map and then disable text labels for the buttons. The result is, user will see the buttons with icons only. You can see a demonstration of the above from the example link below. The demonstration will also show that you can choose to display any specific button on the map instead of both buttons that appears by default. In this example, we can show or hide the "Scroll Wheel" button from the control. For a complete list of available methods for Control Appearance, see the Reference.

View example (gmwControl-buttonStyle.html)

Map Positions

Middle Click Feature is an important part of GMouseWheelControl. It shows the options for Scroll Wheel mouse or starts Click & Pan at the location on the map where you clicked. In order to get the exact location of this click event, it is necessary to know the location of the map as well. getMapPosition() method will return the position of the map relative to the document that was last calculated.

GMouseWheelControl will automatically calculate the position of the map when the control is added and also when user's browser is resized. However, if the position of the map is changed dynamically, for example some contents were added/removed from the document on which the map was added to, you will need to use calculateMapPosition() method. Otherwise, scroll wheel option menu or the click & pan icon will not appear at the correct location, when middle clicked on the map or used Shift + Click.

The example below demonstrates how GMouseWheelControl behaves if location of the map is changed dynamically and the usage of calculateMapPosition() method to fix this issue. Please note that, only Firefox 2 and Opera 9 has been tested to be affected by this position issue and requires the fix.
View example (gmwControl_mapPosition.html)

GMouseWheelControl Reference

Below is the complete reference or descriptions of all the public methods along with their return values that are available from GMouseWheelControl. These methods can be used in your map, once the control has been added.

Control Appearance
Methods Return Value Description
showControlButton() None Shows control buttons where the GMouseWheelControl was added in the map.
hideControlButton() None Hides the control buttons from the map.
controlButtonVisible() Boolean Returns a Boolean value indicating whether the control buttons are visible or not.
enableButtonText() None Buttons will have text labels.
disableButtonText() None Buttons will not have any text labels.
buttonTextEnabled() Boolean Returns a Boolean value indicating if text labels on the buttons enabled or not.
enableButtonIcon() None Buttons will have icons on the left hand side.
disableButtonIcon() None Buttons will not have any icons.
buttonIconEnabled() Boolean Returns a Boolean value indicating if icon on the buttons are enabled or not.
showScrollWheelButton() None Shows the "Scroll Wheel" button on the control
hideScrollWheelButton() None Hides the "Scroll Wheel" button from the control
scrollWheelButtonVisible() Boolean Returns a Boolean value indicating if the "Scroll Wheel" button is visible or not
showClickPanButton() None Shows the "Click & Pan" button on the control
hideClickPanButton() None

Hides the "Click & Pan" button on the control

Note: If this button is hidden, the user may not be able to use the Click & Pan feature unless it is provided by any other means.

clickPanButtonVisible() Boolean Returns a Boolean value indicating if the "Click & Pan" button is visible or not.
Map Positions
Methods Return Value Description
getMapPosition() Object-Literal
posX: int posY: int
Returns the position of the map as "Object-Literal" with integer value relative to the document, which was last calculated.
calculateMapPosition() None Calculates the current position of the map relative to the document.
Scroll Wheel Options
Methods Return Value Description
showScrollWheelOption(posX, posY) None Shows the option menu of Scroll Wheel at the given position. If no position is provided, the menu will be displayed at the last position where it was displayed.
hideScrollWheelOption() None Hides the option menu of Scroll Wheel.
scrollWheelOptionVisible() Boolean Returns a Boolean value indicating if Scroll Wheel menu is visible or not.
enableScrollWheelPanVertical() None Allows google map to pan/move vertically when mouse scroll wheel is rolled up or down.
disableScrollWheelPanVertical() None Disables google map from panning/moving vertically when mouse scroll wheel is rolled up or down.
scrollWheelPanVerticalEnabled() Boolean Returns a Boolean value indicating if option to pan/move google map vertically using mouse scroll wheel enabled or not.
enableScrollWheelPanHorizontal() None Allows google map to pan/move horizontally when mouse scroll wheel is rolled up or down.
disableScrollWheelPanHorizontal() None Disables google map from panning/moving horizontally when mouse scroll wheel is rolled up or down.
scrollWheelPanHorizontalEnabled() Boolean Returns a Boolean value indicating if option to pan/move google map horizontally using mouse scroll wheel enabled or not.
enableScrollWheelZoom() None Allows google map to zoom in/out when mouse scroll wheel is rolled up or down. This function uses Google Map API's enableScrollWheelZoom().
disableScrollWheelZoom() None Disables google map from zooming in/out when mouse scroll wheel is rolled up or down. This function uses Google Map API's disableScrollWheelZoom().
scrollWheelZoomEnabled() Boolean Returns a Boolean value indicating if option to zoom in/out using mouse scroll wheel enabled or not.
getSelectedOption() String Returns a String value indicating which option from Scroll Wheel option menu is selected. If none selected, it returns null. The returned String value would be one of the following three:
  • GMW_PAN_HORIZONTAL
  • GMW_PAN_VERTICAL
  • GMW_ZOOM
Click & Pan Options
Methods Return Value Description
enableClickPan() None Enables Click & Pan mode allowing ther user to pan/move map by mouse pointer location on the map. Middle Click or Shift + Click will start panning. While the map is panning, clicking anywhere on the map will stop panning.
disableClickPan() None Disables Click & Pan mode
clickPanEnabled() Boolean Returns a Boolean value indicating whether Click & Pan mode is enabled or not