Placemark

Extends GeoObject.

Placemark. A geo object with the geometry geometry.Point.

See GeoObjectgeometry.Point

Constructor | Fields | Events | Methods

Constructor

Placemark(geometry[, properties[, options]])

Creates a placemark instance.

Parameters:

Parameter

Default value

Description

geometry*

Type: Number[]|Object|IPointGeometry

Coordinates of the placemark, or a hash describing the geometry, or a reference to the point geometry object.

properties

Type: Object|IDataManager

Placemark data. Can be set as a class instance implementing the IDataManager interface, or as a hash. When options are set to default values, the following data fields are interpreted by a geo object:

  • iconContent — Content of the geo object's icon.
  • iconCaption - Caption for the geo object's icon.
  • hintContent — Content of the geo object's popup hint.
  • balloonContent — Content of the geo object's balloon.
  • balloonContentHeader — Content of the geo object balloon title.
  • balloonContentBody — Content of the main part of the geo object's balloon.
  • balloonContentFooter — Content of the lower part of the geo object's balloon.
    The balloonContent field is a shortcut for the balloonContentBody field, but if they are both set simultaneously, balloonContentBody takes priority. You can also add your own custom fields to the placemark data and use them wherever possible. For example, in the placemark layout or balloon layout.

options

Type: Object

Placemark options.

To change the style and color of an icon, use the following options:

  • preset — Key for the placemark's preset options. The list of available keys is stored in the option.presetStorage description. You can set the preset option together with the iconColor option only if it takes one of the following values:

    • 'islands#icon'
    • 'islands#dotIcon'
    • 'islands#circleIcon'
    • 'islands#circleDotIcon'
  • iconColor — The color of the placemark icon. You can specify it in any format that is acceptable in CSS (for example, by name or in the RGB format). This option is used for standard icons in browsers that support SVG.

    Note

    This option does not work in IE8.

If you want to create your own icon layout, you should specify the following options:

  • iconLayout — Icon layout. Type: constructor for an object with the ILayout interface, or its key in the storage. List of available layouts:

    • 'default#image' — Custom icon image.
    • 'default#imageWithContent' — A custom image for an icon with content.
  • Additional options for the layout.Image and layout.ImageWithContent classes with the "icon" prefix.

Note

To specify the layout of the icon shadow, use the same set of options, but with the "iconShadow" prefix. For example, iconShadowLayout.

You can also set options for individual objects using the Placemark class:

Below are the other options of this class.

options.cursor

"pointer"

Type: String

Type of cursor over a placemark.

options.draggable

false

Type: Boolean

Checks whether the placemark can be dragged.

options.hasBalloon

true

Type: Boolean

Checks whether the placemark has the "balloon" field.

options.hasHint

true

Type: Boolean

Checks whether the placemark has the "hint" field.

options.hideIconOnBalloonOpen

true

Type: Boolean

Hide the placemark when opening the balloon.

options.iconOffset

Type: Number[]

The pixel offset of the icon relative to its set position.

options.iconShape

Type: IGeometryJson|null

The hotspot shape of the placemark. Specified as a JSON description of the pixel geometry of the icon. Use this option when creating your HTML layouts. The coordinates of the figure geometry are counted from the anchor point.

options.interactiveZIndex

true

Type: Boolean

Enables automatically modifying the z-index of the placemark depending on its state.

options.interactivityModel

"default#geoObject"

Type: String

Interactivity model. Available keys and their values are listed in the description of interactivityModel.storage.

options.openBalloonOnClick

true

Type: Boolean

Checks whether to show the balloon when the placemark is clicked on.

options.openEmptyBalloon

false

Type: Boolean

Checks whether to show an empty balloon when the placemark is clicked on.

options.openEmptyHint

false

Type: Boolean

Checks whether to show an empty hint when the mouse pointer hovers over the placemark.

options.openHintOnHover

true

Type: Boolean

Checks whether to show the hint when the mouse pointer hovers over the placemark.

options.pane

"places"

Type: String

The key of the pane where the placemark overlay is placed.

options.pointOverlay

"default#placemark"

Type: String|Function

Key identifier from overlay.storage or the overlay class. The generator function accepts three parameters:

options.syncOverlayInit

false

Type: Boolean

Enables synchronously adding an overlay to the map. By default, overlays are added to the map asynchronously to prevent the browser from hanging when adding a large number of geo objects. However, adding asynchronously does not allow accessing the overlay immediately after adding a placemark to the map.

options.useMapMarginInDragging

true

Type: Boolean

When an object is dragged to the edge of the map, the map center changes automatically. Whether to use map margins when automatically shifting the map center with map.margin.Manager.

options.visible

true

Type: Boolean

Checks placemark visibility.

options.zIndex

Type: Number

The z-index of a placemark in its normal state. Lowest priority.

options.zIndexActive

Type: Number

The z-index of a placemark icon with an open balloon. Highest priority.

options.zIndexDrag

Type: Number

The z-index of a placemark that is being dragged.

options.zIndexHover

Type: Number

The z-index of a placemark when the mouse pointer is hovering over it.

* Mandatory parameter/option.

Examples:

1.

// Creating a placemark.
var placemark = new ymaps.Placemark([55.75, 37.61], {
    balloonContent: '<img src="http://img-fotki.yandex.ru/get/6114/82599242.2d6/0_88b97_ec425cf5_M" />',
    iconContent: "Azerbaijan"
}, {
    preset: "islands#yellowStretchyIcon",
    // Disabling the close balloon button.
    balloonCloseButton: false,
    // The balloon will open and close when the placemark icon is clicked.
    hideIconOnBalloonOpen: false
});
geoMap.geoObjects.add(placemark);

2.

var placemark = new ymaps.Placemark([55.75, 37.61], {}, {
    // Setting the placemark style (circle).
    preset: "islands#circleDotIcon",
    // Setting the placemark color (in RGB format).
    iconColor: '#ff0000'
});
geoMap.geoObjects.add(placemark);

Fields

Name

Type

Description

balloon

geoObject.Balloon

Balloon for a geo object.

Inherited from GeoObject.

editor

geometryEditor.Point

The "Point" geometry editor.

events

event.Manager

Event manager.

Inherited from GeoObject.

geometry

geometry.Point

The "Point" type of geometery.

hint

geoObject.Hint

Geo object hint.

Inherited from GeoObject.

options

option.Manager

Geo object options manager.

Inherited from GeoObject.

properties

data.Manager

Geo object data manager.

Inherited from GeoObject.

state

data.Manager

State of the geo object. Defined by the following fields:

  • active: Boolean - Indicates that a balloon is open on the geo object.
  • hover: Boolean - Indicates that the mouse is currently pointed at the geo object.
  • drag: Boolean - Indicates that the geo object is being dragged

Inherited from GeoObject.

Events

Name

Description

balloonclose

Closing the balloon. Instance of the Event class.

Inherited from GeoObject.

balloonopen

Opening a balloon on a geo object. Instance of the Event class.

Inherited from GeoObject.

beforedrag

Event preceding the "drag" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • position - Coordinates relative to the document. Array in the format [pageX, pageY].
  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • domEvent - Source DOM event (as a DomEvent object), if there is one.
    Names of methods that are accessible via Event.callMethod:
  • setPixelOffset - This method is for correcting the value of the pixel offset that will actually be applied. It takes an argument with the new pixel offset in the form of an array of two numbers.
    If the Event.preventDefault method is called for this event, a subsequent drag event will be canceled.

Inherited from GeoObject.

beforedragstart

Event preceding the "dragstart" event. Instance of the Event class. Names of fields that are available via the Event.get method:

  • position - Coordinates relative to the document. Array in the format [pageX, pageY].
  • domEvent - Source DOM event (as a DomEvent object), if there is one.
    If the Event.preventDefault method is called for this event, any subsequent dragging, as well as the "dragstart" event, will be canceled.

Inherited from GeoObject.

click

Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

contextmenu

Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

dblclick

Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

drag

Dragging a geo object. Instance of the Event class. Names of fields that are available via the Event.get method:

  • position - Coordinates relative to the document. Array in the format [pageX, pageY].
  • pixelOffset - Array of two numbers that describe the pixel offset at this step.
  • domEvent - Source DOM event (as a DomEvent object), if there is one.

Inherited from GeoObject.

dragend

End of geo object dragging. Instance of the Event class. Names of fields that are available via the Event.get method:

  • position - Coordinates relative to the document. Array in the format [pageX, pageY].
  • domEvent - Source DOM event (as a DomEvent object), if there is one.

Inherited from GeoObject.

dragstart

Start of geo object dragging. Instance of the Event class. Names of fields that are available via the Event.get method:

  • position - Coordinates relative to the document. Array in the format [pageX, pageY].
  • domEvent - Source DOM event (as a DomEvent object), if there is one.

Inherited from GeoObject.

editorstatechange

Change in the state of the editor for the geo object's geometry. Instance of the Event class. Names of fields that are available via the Event.get method:

  • originalEvent - Original event of the geometry editor.

Inherited from GeoObject.

geometrychange

Change to the geo object geometry. Instance of the Event class. Names of fields that are available via the Event.get method:

  • originalEvent: IEvent - Original event of the geometry.

Inherited from IGeoObject.

hintclose

Closing the hint. Instance of the Event class.

Inherited from GeoObject.

hintopen

Opening a hint on a geo object. Instance of the Event class.

Inherited from GeoObject.

mapchange

Map reference changed. Data fields:

  • oldMap - Old map.
  • newMap - New map.

Inherited from IParentOnMap.

mousedown

Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseenter

Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseleave

Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mousemove

Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseup

Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

multitouchend

End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface.

Inherited from IDomEventEmitter.

multitouchmove

Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

multitouchstart

Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

optionschange

Change to the object options.

Inherited from ICustomizable.

overlaychange

Change to the geo object overlay. Instance of the Event class. Names of fields that are available via the Event.get method:

  • overlay: IOverlay|null - Reference to the overlay.
  • oldOverlay: IOverlay|null - Previous overlay of the geo object.

Inherited from IGeoObject.

parentchange

The parent object reference changed.

Data fields:

  • oldParent - Old parent.
  • newParent - New parent.

Inherited from IChild.

propertieschange

Change to the geo object data. Instance of the Event class. Names of fields that are available via the Event.get method:

  • originalEvent: IEvent - Original event of the data manager.

Inherited from IGeoObject.

wheel

Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. Instance of the MapEvent class. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

Methods

Name

Returns

Description

getMap()

Map

Returns reference to the map.

Inherited from IParentOnMap.

getOverlay()

vow.Promise

Returns the promise object, which is confirmed by the overlay object at the time it is actually created, or is rejected with an appropriate error message.

Inherited from IGeoObject.

getOverlaySync()

IOverlay|null

The method provides synchronous access to the overlay.

Inherited from IGeoObject.

getParent()

IParentOnMap|null

Returns link to the parent object, or null if the parent element was not set.

Inherited from IChildOnMap.

setParent(parent)

IChildOnMap

Sets the parent object. If the null value is passed, the manager element will only be deleted from the current parent object.

Inherited from IChildOnMap.

Fields details

editor

{geometryEditor.Point} editor

The "Point" geometry editor.

geometry

{geometry.Point} geometry

The "Point" type of geometery.