Class deCarta.Mobile.Pin
A Pin is used to graphically represent a position on the map. It can have a custom image, and when clicked it can display some sort of custom text. Add the pin to a map overlay using the deCarta.Mobile.MapOverlay:addObject() method. Pin extends deCarta.Mobile.OverlayObject.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
deCarta.Mobile.Pin(options)
An OverlayObject used to display a pin on a MapOverlay
|
| Method Attributes | Method Name and Description |
|---|---|
|
click(fn)
Defines a new callback for the click event.
|
|
|
Disables the text for this pin
This both hides the text, and disables the text from appearing the
next time the pin is clicked.
|
|
|
Enables the text for this pin
If the text was disabled, it will not appear when the pin is clicked.
|
|
|
getImage()
Returns the current image for the pin
|
|
|
hideText()
Hides the text for this pin
|
|
|
setImage(image, xOffset, yOffset)
Sets the image element that will be used for the pin
|
|
|
setImageSrc(imageSrc, xOffset, yOffset)
Sets a src value for the pin's image
|
|
|
setRotation(angle)
Sets the rotation angle of the pin
|
|
|
setText(text)
Sets the text to be displayed above the pin (when the pin is selected)
|
|
|
showText()
Unhides the text for this pin
|
Class Detail
deCarta.Mobile.Pin(options)
An OverlayObject used to display a pin on a MapOverlay
- Parameters:
- options
- Options. May contain one or more of the following:
- (string) text: text diplayed on the pin label - optional, default=''
- {HTMLDOMElement} textElement: if this option is set, this will be an element that overrides the standard pin label
- deCarta.Mobile.Position position: the geographic position at which to place the pin, required
- (HTMLDOMElement) image: a DOM image element representing the pin
- (string) imageSrc: a string containing either the URI to an image or a base64 representation of the image
- (int) xOffset: Number of pixels to shift the pin to the left (set to half of the image width to center the image over the position on the map), optional, default=0
- (int) yOffset: Number of pixels to shift the pin up (set to the full height of the image to place the image above the position on the map), optional, default=0
- (function) onClick: a callback function that will be notified if the pin is clicked
- (function) onLabelClick: a callback that will be notified if the label is clicked
- (boolean) textVisible: Controls visibility of pin text. Default=false (click pin to toggle to true)
Method Detail
click(fn)
Defines a new callback for the click event.
- Parameters:
- fn
disableText()
Disables the text for this pin
This both hides the text, and disables the text from appearing the
next time the pin is clicked.
enableText()
Enables the text for this pin
If the text was disabled, it will not appear when the pin is clicked.
Enabling the text re-enables the appear-on-click functionality.
{HTMLDOMElement}
getImage()
Returns the current image for the pin
- Returns:
- {HTMLDOMElement} The HTML DOM Element of the image for the pin
hideText()
Hides the text for this pin
setImage(image, xOffset, yOffset)
Sets the image element that will be used for the pin
- Parameters:
- {Image} image
- the image
- {int} xOffset
- Number of pixels to shift the image to the left of the pin position (use half the image width to center on position) (Optional, default=0)
- {int} yOffset
- Number of pixels to shift the image upward (use the full image height to place image above position) (Optional, default=0)
setImageSrc(imageSrc, xOffset, yOffset)
Sets a src value for the pin's image
- Parameters:
- {HTMLDOMElement} imageSrc
- Source of the image (you can use imageSrc to convert from a URI or base64 string)
- {int} xOffset
- The NEW Number of pixels to shift the image to the left of the pin position (use half the image width to center on position) (Optional, default=0)
- {int} yOffset
- The NEW Number of pixels to shift the image upward (use the full image height to place image above position) (Optional, default=0)
setRotation(angle)
Sets the rotation angle of the pin
- Parameters:
- {float} angle
- Angle to rotate the pin, counter-clockwise
setText(text)
Sets the text to be displayed above the pin (when the pin is selected)
- Parameters:
- {string} text
- String to associate with pin
showText()
Unhides the text for this pin