davidjeddy / yii2-leaflet-draw-plugin
为2amigo Leaflet扩展添加Leaflet.Draw功能的插件。
0.1.0
2015-09-25 16:22 UTC
Requires
- 2amigos/yii2-leaflet-extension: ~1.0
- bower-asset/leaflet.draw: ~0.2
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2024-09-05 19:01:53 UTC
README
为2amigo Leaflet扩展添加Leaflet Draw功能的Yii 2插件。
安装
通过 composer 安装此扩展是首选方式。
运行以下命令:
php composer.phar require "davidjeddy/yii2-leaflet-draw-plugin" "*"
或者将以下内容添加到应用程序的 composer.json
文件的要求部分:
"davidjeddy/yii2-leaflet-draw-plugin" : "*"
使用方法
// first lets setup the center of our map $center = new \dosamigos\leaflet\types\LatLng(['lat' => 51.508, 'lng' => -0.11]); // now lets create a marker that we are going to place on our map $marker = new \dosamigos\leaflet\layers\Marker(['latLng' => $center, 'popupContent' => 'Hi!']); // The Tile Layer (very important) $tileLayer = new \dosamigos\leaflet\layers\TileLayer([ 'urlTemplate' => 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg', 'clientOptions' => [ 'attribution' => 'Tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">, Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>', 'subdomains' => '1234', ] ]); // now our component and we are going to configure it $leaflet = new \dosamigos\leaflet\LeafLet([ 'center' => $center, // set the center ]); // init the 2amigos leaflet plugin provided by the package $drawFeature = new \davidjeddy\leaflet\plugins\draw\Draw(); // optional config array for leadlet.draw $drawFeature->options = [ "position" => "topright", "draw" => [ "polyline" => [ "shapeOptions" => [ "color" => "#ff0000", "weight" => 10 ] ], "polygon" => [ "allowIntersection" => false, // Restricts shapes to simple polygons "drawError" => [ "color" => "#e1e100", // Color the shape will turn when intersects "message" => "<b>Oh snap!</b> you can't draw that!" // Message that will show when intersect ], "shapeOptions" => [ "color" => "#bada55" ] ], "circle" => true, // Turns off this drawing tool "rectangle" => [ "shapeOptions" => [ "clickable" => false ] ] ] ]; // Different layers can be added to our map using the `addLayer` function. $leaflet->addLayer($marker) // add the marker ->addLayer($tileLayer) // add the tile layer ->installPlugin($drawFeature); // add draw plugin // we could also do echo $leaflet->widget(['options' => ['style' => 'min-height: 300px']]);
测试
TODO
待办事项
添加 edit
菜单功能 添加自定义标记功能
贡献
请参阅./docs/CONTRIBUTING 获取详细信息。
致谢
许可证
BSD许可证(BSD)。请参阅./docs/License File 获取更多信息。
特别感谢
Web开发从未如此有趣!
http://2amigos.us/
(http://http://sourcetoad.com/)
Sourcetoad是一家位于佛罗里达州坦帕的获奖应用开发公司。我们是跨平台Web和移动应用开发的专家。
http://sourcetoad.com/