Geofield Yandex Maps

Open Bugs: 
0
Development Status: 
Seeking co-maintainer(s)
Under active development

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

API

Programmaticaly show map with marker

<?php
$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

<?php
$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' => '',
);
?>

#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]}',
    auto_centering: true,
    auto_zooming: true
  });
});

before that do not forget add library:

<?php
drupal_add_library
('geofield_ymap', 'geofield_ymap');
?>

demo

Releases: 
7.x-1.x-dev
Release Dates: 
01/02/2014