setHeight('400px'); $this->setCenter(0, 0); $this->setZoom(13); $this->withMapMeta('type', $this->getMapFieldType()); parent::__construct($name, $attribute = null, $resolveCallback); } /** * Set the height for the map. * * @param mixed $height * * @return $this */ public function setHeight($height) { return $this->withMapMeta('height', $height); } /** * Set the zoom for the map. * * @param mixed $level * * @return $this */ public function setZoom($level) { return $this->withMapMeta('zoom', $level); } /** * Set the position for the map. * * @param mixed $latitude * @param mixed $longitude * * @return $this */ public function setCenter($latitude, $longitude) { return $this->withMapMeta('center', [ 'latitude' => $latitude, 'longitude' => $longitude, ]); } /** * Add meta data for the map. * * @param mixed $key * @param mixed $value */ protected function withMapMeta($key, $value) { $existingMapMeta = $this->meta['map'] ?? []; return $this->withMeta([ 'map' => array_merge($existingMapMeta, [ $key => $value, ]), ]); } /** * Get component name. * * @return string */ public function getMapFieldType() { return Str::kebab(class_basename($this)); } }