dandarie / phpgmaps
Laravel版的BIOSTALL的CodeIgniter Google Maps API实现,最初由Appitventures的Michael Hopkins创建。
此包的官方仓库似乎已消失,因此该包已被冻结。
0.3.4
2015-09-21 20:06 UTC
Requires
- php: >=5.4.0
- laravel/framework: 5.*
This package is not auto-updated.
Last update: 2021-04-02 23:45:36 UTC
README
此仓库的目的是保持appitventures/phpgmaps活跃,希望暂时替代直到他们再次提供仓库,或者继续维护并保持与Laravel未来版本的兼容性。
目前仅支持Laravel 5.*。
安装更改
将仓库添加到composer.json中的新命名空间下
"require": {
"dandarie/phpgmaps": "~0.3.4"
}
然后向config/app.php
添加服务提供者条目
'dandarie\Phpgmaps\PhpgmapsServiceProvider',
以及外观(在config/app.php
中向下)
'Gmaps' => 'dandarie\Phpgmaps\Facades\Phpgmaps',
#原始README
Phpgmaps
BIOINSTALL的CodeIgniter库的非CI实现。
我在使用CodeIgniter时发现这个库非常有用。但是,在Laravel项目中使用它需要进行一些修改。我无法为此类的实际“重活”承担任何信用。
示例
以下代码将提示用户访问其地理位置,然后创建一个以用户经纬度为中心的地图
Route::get('/', function(){
$config = array();
$config['center'] = 'auto';
$config['onboundschanged'] = 'if (!centreGot) {
var mapCentre = map.getCenter();
marker_0.setOptions({
position: new google.maps.LatLng(mapCentre.lat(), mapCentre.lng())
});
}
centreGot = true;';
Gmaps::initialize($config);
// set up the marker ready for positioning
// once we know the users location
$marker = array();
Gmaps::add_marker($marker);
$map = Gmaps::create_map();
echo "<html><head><script type="text/javascript">var centreGot = false;</script>".$map['js']."</head><body>".$map['html']."</body></html>";
});
更多示例
BIOSTALL有一个很棒的网站展示了如何使用此类做所有事情。没有必要重新发明轮子,所以这里有。需要注意的是,$this->googlemaps
现在变成了Gmaps::
。