百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

laravel-maps

> 后端框架
开源

您的 laravel maps 库。

365 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

您的 laravel maps 库。

Laravel maps

This package allows you to easily use leaflet.js or google maps to create a map in your laravel project.

Installation

You can install the package via composer:

bash
composer require larswiegers/laravel-maps

If you want to customize the map views more then you can publish the views:

bash
php artisan vendor:publish --provider="Larswiegers\LaravelMaps\LaravelMapsServiceProvider"

Supported map types

What Basic map Different map types Centerpoint Basic markers Use bounds Zoomlevel Can use different tiles Can be used multiple times on the same page
Leaflet ✅ ❌ ✅ ✅ ❌ ✅ ✅ ✅
Google maps ✅ ✅ ✅ ✅ ✅ ✅ ✅ ❌

Tilehosts

Openstreetmap

Openstreetmap is a creative commence tile library created by volunteers. No configuration has to be set to use as it is the default tilehost for this library. More information can be found here: openstreetmap.org

Mapbox

Mapbox is a for profit company that also offers free keys. Their map can be more accurate / precise. To get your free key go to mapbox.com Once logged in you can get your free key and use it by placing it in the env file like this MAPS_MAPBOX_ACCESS_TOKEN.

Attribution

Mapbox requires you to have attribution when you use their tilehost. More information on that here: https://docs.mapbox.com/help/getting-started/attribution/ We provide a default value if you use mapbox. But if you want to customize it you can pass in the te text via the attribution attribute. Like this:

Usage

Leaflet

blade
// Leaflet
// A basic map is as easy as using the x blade component.

// Set the centerpoint of the map:
 52.16, 'long' => 5]">

// Set a zoomlevel:

// Set markers on the map:
 52.16444513293423, 'long' => 5.985622388024091]]">

Do note that if you want to use multiple maps on the same page that you need to specify an id per map.

Leaflet Version

By default we use the latest version of leaflet, but if you want to use a different version just pass it in via a parameter:

blade
// Set leafletVersion to desired version:

Google Maps

…

Google maps api key

You can get an api key here:

Create an api key and enable the Maps Javascript API in the console aswell. Place the api key in the env file like this MAPS_GOOGLE_MAPS_ACCESS_TOKEN

Advanced Markers

This package now uses Google Maps' AdvancedMarkerElement (introduced in v3.56) instead of the deprecated google.maps.Marker class. Advanced Markers provide several improvements including:

  • Better performance and rendering
  • Support for custom HTML content including text labels next to markers
  • Improved accessibility
  • Future-proof implementation aligned with Google's latest recommendations

Read more about Advanced Markers: Google Maps Advanced Markers Documentation

Good to know

Double quotes need to be escaped, i.e. add a backslash followed by double quotes (/")

Usage in livewire

This library does not support livewire out of the box, but some users have found a workaround to work. Please see this issue for more information: https://github.com/LarsWiegers/laravel-maps/issues/34

Feel free to PR a livewire component if you have the time.

Testing

To run the tests just use the following component:

bash
composer test

Testing is done through rendering the blade components and making assertions on the html outputted. While this is great for initial testing it does lack some more certainty. In the future an browser test may be needed to further make sure that the code works as intended.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

  • Lars Wiegers
  • All Contributors

License

The MIT License (MIT). Please see License File for more information.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPgooglemapshacktoberfestlaravelleafletjs

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架