承接 lukyrys/nette-forms-gpspicker 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lukyrys/nette-forms-gpspicker

Composer 安装命令:

composer require lukyrys/nette-forms-gpspicker

包简介

Google Maps based picker of coordinates for Nette Framework.

README 文档

README

GPS coordinates picker. Try it now!

Drivers
  • Google Maps API v3
  • Mapy.cz API v4
  • Nokia Maps API v2
  • OpenStreetMap (using Google Maps API v3)
License

New BSD

Dependencies

Nette 2.4.x

Demo

http://vojtechdobes.com/gpspicker/

Installation

  1. Get the source code from Github or via Composer (vojtech-dobes/nette-forms-gpspicker).
  2. Register VojtechDobes\NetteForms\GpsPickerExtension as extension.
  3. Link appropriate maps API SDK and client/nette.gpsPicker.js in app/templates/@layout.latte.
extensions:
	gpspicker: VojtechDobes\NetteForms\GpsPickerExtension

In Nette 2.0, registration is done in app/bootstrap.php:

$configurator->onCompile[] = function ($configurator, $compiler) {
	$compiler->addExtension('gpspicker', new VojtechDobes\NetteForms\GpsPickerExtension);
};
	<script src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
	<script src="{$basePath}/libs/nette.gpsPicker.js"></script>
</body>

(for example when using Google Maps API v3)

Usage

$form->addGpsPicker('coords', 'Coordinates:');

You can add some options (every option has also some like setter thing):

$form->addGpsPicker('coords', 'Coordinates:', array(
	'type' => VojtechDobes\NetteForms\GpsPicker::TYPE_SATELLITE,
	'zoom' => 1, // something like whole planet I guess
	'size' => array(
		'x' => 411,
		'y' => 376,
	),
));

If you prefer manual rendering, caption can be omitted:

$form->addGpsPicker('coords', array(
	'type' => ...
	...
));

Returned value is instance of GpsPoint with lat and lng properties. It inherits from Nette\Object.

$lat = $form->values->coords->lat;
$lng = $form->values->coords->lng;

You can set value (respectively default value) like this:

$form['coords']->setDefaultValue(array(
	'lat' => 50.103245,
	'lng' => 14.474691,
));

Validation

use VojtechDobes\NetteForms\GpsPicker as Gps;

Now you can easily add various constraints on desired GPS:

$form->addGpsPicker('coords')
	->addRule(Gps::MIN_LAT, 'Minimal latitude must be %f.', 20)
	->addRule(Gps::MIN_LNG, 'Minimal longitude must be %f.', 40)
	->addRule(Gps::MAX_LAT, 'Maximum latitude must be %f.', 20)
	->addRule(Gps::MAX_LNG, 'Maximum longitude must be %f.', 40)
	->addRule(Gps::MIN_DISTANCE_FROM, 'Minimal distance from Prague must be %d m.', array(15000, array(
		'lat' => 50.083,
		'lng' => 14.423,
	)));
	->addRule(Gps::MAX_DISTANCE_FROM, 'Maximum distance from Prague must be %d m.', array(100000, array(
		'lat' => 50.083,
		'lng' => 14.423,
	)));

First four rules will be also validated client-side.

Manual rendering

If the user doesn't support Javascript or gets offline, picker provides several inputs for setting coordinates manually. You can easily render them manually as well as whole complete element.

{form formName}
	...

	{gpspicker coords}
		{gpspicker:label lat}Latitude:{/gpspicker:label} {gpspicker:input lat}
		{gpspicker:label lng}Longitude:{/gpspicker:label} {gpspicker:input lng}
	{/gpspicker}
{/form}

Search by address

Enabled by default, GpsPicker supports searching map by typing the address. Extra <input> element will be prepended to map, enhanced by Google Places Autocomplete service.

If you like to render it manually, use search key:

{gpspicker coords}
	{gpspicker:label search /} {gpspicker:input search}
{/gpspicker}

You can disable/enable search feature with enableSearch/disableSearch pair of methods:

$form->addGpsPicker('coords', 'Coordinates:')
	->disableSearch();

Or in constructor:

$form->addGpsPicker('coords', 'Coordinates:', array(
	'search' => FALSE,
));

Providers

If you are afraid of exhausting API rate limit of Google Maps, you can use alternative provider as well. All you have to do is to link their appropriate API SDK and set the driver:

$form->addGpsPicker('coords', 'Coordinates:')
	->setDriver(GpsPicker::DRIVER_SEZNAM);

Available providers are:

Google

Feature Value
Usage default (manually by calling ->setDriver(GpsPicker::DRIVER_GOOGLE))
Search by address yes
Supported types GpsPicker::TYPE_ROADMAP, GpsPicker::TYPE_SATELLITE, GpsPicker::TYPE_HYBRID, GpsPicker::TYPE_TERRAIN
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

Nokia

Feature Value
Usage ->setDriver(GpsPicker::DRIVER_NOKIA)
Search by address no
Supported types GpsPicker::TYPE_NORMAL, GpsPicker::TYPE_SATELLITE, GpsPicker::TYPE_TERRAIN
<script src="http://api.maps.nokia.com/2.2.1/jsl.js?with=all" charset="utf-8"></script>
<script>
	nokia.Settings.set('appId', 'XXX');
	nokia.Settings.set('authenticationToken', 'XXX');
</script>

OpenStreetMap

Feature Value
Usage ->setDriver(GpsPicker::DRIVER_OPENSTREETMAP)
Search by address no
Supported types GpsPicker::TYPE_ROADMAP, GpsPicker::TYPE_SATELLITE, GpsPicker::TYPE_HYBRID, GpsPicker::TYPE_TERRAIN
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>

Seznam (Mapy.cz)

Feature Value
Usage ->setDriver(GpsPicker::DRIVER_SEZNAM)
Search by address no
Supported types GpsPicker::TYPE_BASE, GpsPicker::TYPE_BIKE, GpsPicker::TYPE_HISTORIC, GpsPicker::TYPE_HYBRID,
GpsPicker::TYPE_OPHOTO, GpsPicker::TYPE_TRAIL, GpsPicker::TYPE_TURIST
<script src="http://api4.mapy.cz/loader.js"></script>
<script>Loader.load()</script>

lukyrys/nette-forms-gpspicker 适用场景与选型建议

lukyrys/nette-forms-gpspicker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.66k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「Forms」 「nette」 「maps」 「gps」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 lukyrys/nette-forms-gpspicker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lukyrys/nette-forms-gpspicker 我们能提供哪些服务?
定制开发 / 二次开发

基于 lukyrys/nette-forms-gpspicker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 18
  • 开发语言: PHP

其他信息

  • 授权协议: New
  • 更新时间: 2017-02-26