Skip to content

Add Yandex Maps and Yandex Geocoder support#1868

Open
Teese999 wants to merge 3 commits intocode4recovery:mainfrom
Teese999:main
Open

Add Yandex Maps and Yandex Geocoder support#1868
Teese999 wants to merge 3 commits intocode4recovery:mainfrom
Teese999:main

Conversation

@Teese999
Copy link

@Teese999 Teese999 commented Feb 1, 2026

Summary

This PR adds support for Yandex Maps as an alternative map provider and Yandex Geocoder for accurate address geocoding in Russia, Ukraine, and CIS countries.

Motivation

The default geocoding service (geo.code4recovery.org) sometimes provides inaccurate results for addresses in Russia, Ukraine, and other CIS countries. Yandex services are more accurate for these regions.

Changes

Map Display

  • Add map provider selection in settings (OpenStreetMap/Yandex Maps)
  • Add Yandex Maps API key configuration field
  • Implement dual map provider support in maps.js
  • Conditionally load Leaflet or Yandex Maps scripts based on selection
  • Support all existing map features (markers, popups, bounds, search)

Geocoding

  • Add geocoding provider selection (default/Yandex Geocoder)
  • Implement tsml_geocode_yandex() function using Yandex Geocoder API
  • Clear address cache when switching geocoding providers
  • Maintain existing geocoding cache system

Admin Panel

  • Add map_provider to admin localized script data
  • Fix map initialization to wait for ymaps.ready() callback
  • Ensure proper map centering using actual location coordinates

Backward Compatibility

Fully backward compatible - no breaking changes

  • Defaults to Leaflet + default geocoder (existing behavior)
  • All new features are optional
  • Existing cached addresses remain valid
  • No configuration required for existing users

Configuration

Users can enable Yandex features in Meetings → Settings:

  1. Map Provider: Choose between OpenStreetMap (Leaflet) or Yandex Maps
  2. Yandex Maps API Key: Enter API key from https://developer.tech.yandex.ru/
  3. Geocoding Provider: Choose between default or Yandex Geocoder (recommended for CIS countries)

Testing

  • ✅ Tested with both Leaflet and Yandex Maps providers
  • ✅ Tested with both geocoding providers
  • ✅ All existing features work correctly (markers, popups, search)
  • ✅ Backward compatibility verified (defaults work as before)
  • ✅ Admin panel map display works correctly
  • ✅ Address geocoding accurate for Russia/Ukraine addresses

Use Cases

Recommended for:

  • Organizations in Russia, Ukraine, Belarus, Kazakhstan
  • Any site serving CIS countries
  • Sites needing accurate Cyrillic address geocoding

Example:
https://na-rnd.ru/meetings/donbass-2/

- Add map provider selection in settings (OpenStreetMap/Yandex Maps)
- Add Yandex Maps API key configuration field
- Implement dual map provider support in maps.js
- Conditionally load Leaflet or Yandex Maps scripts based on selection
- Support all existing map features (markers, popups, bounds, search)
- Maintain backward compatibility with default Leaflet provider
- Fix map initialization to wait for ymaps.ready() callback
- Add map_provider to admin localized script data
- Fix map centering to use actual location coordinates instead of default Moscow
- Ensure setMapMarkers is called after Yandex Maps API is fully loaded
- Add geocoding provider selection (default/Yandex)
- Implement tsml_geocode_yandex() function using Yandex Geocoder API
- Clear address cache when switching geocoding providers
- Recommended for Russia, Ukraine, and CIS countries for accurate addresses
- Fixes issue with addresses being incorrectly geocoded by default provider
wp_enqueue_style('leaflet', 'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css', [], '1.9.4');
// Load map provider scripts
if ($tsml_map_provider == 'yandex' && !empty($tsml_yandex_api_key)) {
wp_enqueue_script('yandex-maps', 'https://api-maps.yandex.ru/2.1/?apikey=' . esc_attr($tsml_yandex_api_key) . '&lang=ru_RU', [], null, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the locale here be dynamic? esc_attr(get_locale())

@joshreisner
Copy link
Contributor

thanks for the contribution! we'll discuss it at our next team meeting - saturday at 1pm New York time - you'd be welcome to join us if that time works for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants