Skip to content
  1. Extras
  2. Mapex2

Mapex2

The component adds to MODX a new input field type: Yandex.Map (mapex.yandexMap).

Component adds a new input field type to MODX

Features

The component lets you draw the following objects on the map:

  • Points. Any number of points; for each you set Text, Color (from Yandex.Maps presets), Balloon text
  • Lines. Any number of lines; for each: line color, width, opacity, balloon text
  • Polygons. Any number of polygons; for each: border color, fill color, line width, opacity, balloon text
  • Route. You can add one route between two points on the map.

For each map its settings are saved:

  • map type (map, satellite, hybrid, public map, public + satellite),
  • map center coordinates,
  • map zoom level.

This lets the site display the map exactly as in the admin interface.

The admin includes search on the map by address or name.

You can add several maps to one resource by creating multiple TV fields.

Snippets

mapexMap

The snippet renders the map on the frontend using Yandex.Maps API 2.0.

Snippet parameters:

NameDefaultDescription
&tvNameName of the TV parameter that holds the map. Use together with &resource
&resourcecurrent resourceId of the resource that has the map. Use together with &tvName
&mapJSON string with the map. Alternative way to specify which map to show. If set, &tvName and &resource are ignored. Example: [[mapexMap? &map=`[[*tvMap]]`]]
&mapIdmapexMapMap id. Used when generating javascript. If there are several maps on one page, use different mapId
&width500pxMap width, e.g. 500px or 100%. Always specify units.
&height400pxMap height
&containerCssClassCSS class for the wrapper block around the map
&mapTplmapex.Map.TplMain chunk for map output
&placemarkTplmapex.Placemark.TplChunk for point output
&polygonTplmapex.Polygon.TplChunk for polygon output
&polylineTplmapex.Polyline.TplChunk for line output
&routeTplmapex.Route.TplChunk for route output
&controlsmapTools typeSelector zoomControl searchControl miniMap trafficControl scaleLineSet of controls on the map. See Yandex.Maps 2.0 docs
&includeJS1Whether to include the Yandex.Maps script on the page

mapexMap21

The snippet renders the map on the frontend using Yandex.Maps API 2.1.

Snippet parameters are almost the same; only differences are listed:

NameDefaultDescription
&mapTplmapex.Map21.TplMain chunk for map output
&placemarkTplmapex.Placemark21.TplChunk for point output
&polygonTplmapex.Polygon21.TplChunk for polygon output
&polylineTplmapex.Polyline21.TplChunk for line output
&routeTplmapex.Route21.TplChunk for route output
&controlsdefaultSet of controls on the map. See Yandex.Maps 2.1 docs

Component settings

In component settings (System settings, namespace mapex2) you can set the initial position, zoom and map type in the admin, and show or hide the internal field that stores the map state in JSON.

The component requires jQuery. In settings you can set where to load it from. If another admin component also uses jQuery, conflicts may occur from loading it twice; in that case clear the mapex2_manager_jquery_url setting.

Yandex.Maps API support

The component admin uses Yandex.Maps API 2.0. So far it has not been possible to switch it to API 2.1, as the API changed significantly.

On the frontend, both API 2.0 (snippet mapexMap) and 2.1 (snippet mapexMap21) are supported.

Note: API 2.1 supports multi-routes, but because the admin uses the older API, this feature is not available in the component.