Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yunusga/carbon-field-map-yandex
Carbon Fields extension, that adds a Map Yandex field type
https://github.com/yunusga/carbon-field-map-yandex
carbon-fields wordpress wordpress-plugin
Last synced: 14 days ago
JSON representation
Carbon Fields extension, that adds a Map Yandex field type
- Host: GitHub
- URL: https://github.com/yunusga/carbon-field-map-yandex
- Owner: yunusga
- License: gpl-3.0
- Created: 2022-06-24T02:39:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-25T06:54:01.000Z (over 2 years ago)
- Last Synced: 2024-10-15T09:10:12.527Z (29 days ago)
- Topics: carbon-fields, wordpress, wordpress-plugin
- Language: JavaScript
- Homepage:
- Size: 411 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Carbon Fields Map Yandex
The map field provides a Yandex-powered map with an address search field for [Carbon Fields](https://github.com/htmlburger/carbon-fields).
```php
Field::make( 'map_yandex', 'crb_map', __( 'Yandex Map' ) )
```## Install via Composer
```bash
composer require yunusga/carbon-field-map-yandex
```## Information
The field stores several pieces of related information:
| Atribute | Description | Value Type | Value |
| ------------| -------------------- | ------------ | -------------------------------------- |
| `'value'` | Latitude & Longitude | `(string)` | 11.370946,142.591472 |
| `'lat'` | Latitude | `(float)` | 11.370946 |
| `'lng'` | Longitude | `(float)` | 142.591472 |
| `'address'` | Address | `(string)` | The lowest point of the Mariana Trench |
| `'zoom'` | Zoom level | `(int)` | 4 |### Yandex Maps JS Key setup
As of October 11, 2018, Yandex requires users to generate an API key in order to use the Yandex Maps API:
You can get your API key here: https://developer.tech.yandex.ru/services/3/
Once you're ready with the process of generating a key, you'll need to provide the key to Carbon Fields through a filter:
```php
/**
* Provide the Yandex Maps API key to Carbon Fields
*
* @param string $key Yandex JS API key.
*/
function crb_get_yandex_maps_api_key( $key ) {
return 'your key goes here';
}
add_filter( 'carbon_fields_map_yandex_field_api_key', 'crb_get_yandex_maps_api_key' );
```## Config methods
### `set_position( $lat, $lng, $zoom )`
Set the default position on the map specified by `$lat` and `$lng` and the default zoom level to `$zoom` (zoom `0` corresponds to a map of the Earth fully zoomed out).
```php
Field::make( 'map_yandex', 'crb_company_location', __( 'Location' ) )
->set_help_text( __( 'drag and drop the pin on the map to select location' ) )
```## Usage
To get all the location data as an array, you can use the `map_yandex` type in the retrieval functions. Example:
```php
// Get the location data.
$map_yandex = carbon_get_post_meta( $post_id, $field_name );
```## Value Format
```php
array(
'value' => '11.370946,142.591472',
'lat' => 11.370946,
'lng' => 142.591472,
'zoom' => 4,
'address' => 'The lowest point of the Mariana Trench',
)
```