diff --git a/resources/views/latlong-yandex.blade.php b/resources/views/latlong-yandex.blade.php
new file mode 100644
index 0000000..2348293
--- /dev/null
+++ b/resources/views/latlong-yandex.blade.php
@@ -0,0 +1,233 @@
+
+
+
@@ -75,6 +95,9 @@ public static function showField()
HTML;
+ }
+
+
});
};
}
diff --git a/src/Latlong.php b/src/Latlong.php
index 447745b..680d102 100644
--- a/src/Latlong.php
+++ b/src/Latlong.php
@@ -53,11 +53,21 @@ public static function getAssets()
* @param string $column
* @param array $arguments
*/
- public function __construct($column, $arguments)
+ public function __construct($columns, $arguments)
{
- $this->column['lat'] = (string)$column;
+ $this->column['lat'] = (string)$columns;
$this->column['lng'] = (string)$arguments[0];
+ if (in_array('address', $arguments)) {
+ $this->column['address'] = 'address';
+ array_shift($arguments);
+ }
+
+ if (in_array('zoom', $arguments)) {
+ $this->column['zoom'] = 'zoom';
+ array_shift($arguments);
+ }
+
array_shift($arguments);
$this->label = $this->formatLabel($arguments);
@@ -108,18 +118,23 @@ public function setAutoPosition($bool) {
*/
public function render()
{
- $this->script = Extension::getProvider()
- ->setParams([
- 'zoom' => $this->zoom
- ])
- ->setAutoPosition($this->autoPosition)
- ->applyScript($this->id);
+// $this->script = Extension::getProvider()
+// ->setParams([
+// 'zoom' => $this->zoom
+// ])
+// ->setAutoPosition($this->autoPosition)
+// ->applyScript($this->id);
$variables = [
'height' => $this->height,
'provider' => Extension::config('default'),
];
+
+ $this->view = 'laravel-admin-latlong::latlong-yandex';
+
+
+ $this->addVariables($variables);
- return parent::render()->with($variables);
+ return parent::fieldRender();
}
}
diff --git a/src/LatlongServiceProvider.php b/src/LatlongServiceProvider.php
index 2a47905..e303044 100644
--- a/src/LatlongServiceProvider.php
+++ b/src/LatlongServiceProvider.php
@@ -25,4 +25,4 @@ public function boot(Extension $extension)
Show\Field::macro('latlong', Extension::showField());
});
}
-}
\ No newline at end of file
+}
diff --git a/src/Map/Yandex.php b/src/Map/Yandex.php
index 88f0c96..711bf62 100644
--- a/src/Map/Yandex.php
+++ b/src/Map/Yandex.php
@@ -7,44 +7,189 @@ class Yandex extends AbstractMap
/**
* @var string
*/
- protected $api = '//api-maps.yandex.ru/2.1/?lang=ru_RU';
+ protected $api = '//api-maps.yandex.ru/2.1/?apikey=%s&lang=ru_RU';
/**
* {@inheritdoc}
*/
public function applyScript(array $id)
{
- return <<
getParams('zoom')}
- });
-
- var myPlacemark = new ymaps.Placemark([lat.val(), lng.val()], {
- }, {
- preset: 'islands#redDotIcon',
- draggable: true
- });
-
- myPlacemark.events.add(['dragend'], function (e) {
- lat.val(myPlacemark.geometry.getCoordinates()[0]);
- lng.val(myPlacemark.geometry.getCoordinates()[1]);
- });
-
- myMap.geoObjects.add(myPlacemark);
- });
-
- }
-
- init('{$id['lat']}{$id['lng']}');
- })();
-EOT;
+ if (isset($id['address'])) {
+ return <<