Geofield 2.x widget, Geofield formatter, Views handler, Form element and Text filter with Yandex.Maps 2.1

Drupal 8 version.

API

Programmaticaly show map with marker

$map = array(
  '#theme' => 'geofield_ymap',
  '#map_type' => 'yandex#map', // optionaly, default 'yandex#map'
  '#map_center' => array(37, 55), // optionaly, default auto centering
  '#map_zoom' => 12, // optionaly, default auto zooming
  '#map_auto_centering' => TRUE, // optionaly, default TRUE
  '#map_objects' => '{"type":"Point","coordinates":[37.62817382812449,55.75485888286848]}', // GeoJSON, optionaly
);
$output = render($map);

demo

Show map with marker via html (without php)

Add to node content:

<div class="geofield-ymap" data-map-objects='{"type":"Point","coordinates":[37,55]}'></div>

Enable setting "Use loader" on module settings page.

demo

Usage form element

$form['location'] = array(
  '#type' => 'geofield_ymap',
  '#title' => 'Location',
  '#description' => 'Select control and click to map for add object on map. Double click on object to remove it.',
  '#map_multiple' => TRUE,
  '#map_center' => array(55.733835, 37.588227),
  '#map_zoom' => 12,
  '#map_auto_centering' => TRUE,
  '#map_object_types' => array('point', 'line', 'polygon'),
);

#default_value contains geometry in GeoJSON or json array of objects like [{"type":"Point","coordinates":[55,37]},{"type":"Point","coordinates":[37,55]}]

Demo.

Add map with marker from Javascript

ymaps.ready(function () {
  // for <div id="my-map" style="width:100%; height:400px;"></div>
  var map = Drupal.geofieldYmap.mapInit('my-map', {
    objects: '{"type":"Point","coordinates":[37.62,55.75]}',
    autoCentering: true,
    autoZooming: true
  });
});

before that do not forget add library:

drupal_add_library('geofield_ymap', 'geofield_ymap');

demo

Project information

  • caution Minimally maintained
    Maintainers monitor issues, but fast responses are not guaranteed.
  • caution No further development
    No longer developed by its maintainers.
  • Project categories: Site structure
  • chart icon970 sites report using this module
  • Created by xandeadx on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases