Skip to content

Commit 6ffa574

Browse files
committed
feat(font awesome 6): implement icon pins using svgs
1 parent c342eef commit 6ffa574

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace App\Http\Controllers\API\v3\FontAwesome\v6;
4+
5+
use App\Actions\FontAwesome\v6\GetIconMarkup;
6+
use App\Actions\FontAwesome\v6\GetLabelMarkup;
7+
use App\Http\Controllers\Controller as Controller;
8+
use Illuminate\Http\Request;
9+
10+
class PinController extends Controller
11+
{
12+
public function show(Request $request)
13+
{
14+
if ($request->has('icon')) {
15+
return $this->showIconPin($request);
16+
} else {
17+
return $this->showTextPin($request);
18+
}
19+
}
20+
21+
protected function showIconPin(Request $request)
22+
{
23+
// GET MARKER CONFIG
24+
$markerSize = $request->get('size', 100);
25+
26+
// FOREGROUND ICON
27+
$foregroundIcon = $request->get('icon') ?: null;
28+
$foregroundIconColor = '#'.$request->get('color', '000');
29+
$foregroundIconMarkup = GetIconMarkup::run($foregroundIcon);
30+
31+
// FOREGROUND ICON SHIFTING
32+
$foregroundXShiftPercent = $request->get('hoffset', 0) / $markerSize * 100.00;
33+
$foregroundYShiftPercent = $request->get('voffset', 0) / $markerSize * 100.00;
34+
35+
// FOREGROUND SIZING
36+
$foregroundIconSize = $request->get('iconsize', $markerSize / 3);
37+
$foregroundIconHeightPercent = $foregroundIconSize / $markerSize * 100.00;
38+
$foregroundIconYOffset = 35 - ($foregroundIconHeightPercent / 2.00) + $foregroundYShiftPercent;
39+
$foregroundIconXOffset = 0 + $foregroundXShiftPercent;
40+
41+
// BACKGROUND ICON
42+
$backgroundIcon = 'fa-solid fa-location-pin';
43+
$backgroundIconColor = '#'.$request->get('background', 'CCC');
44+
$backgroundIconMarkup = GetIconMarkup::run($backgroundIcon);
45+
46+
// LABEL
47+
$labelMarkup = GetLabelMarkup::run(request: $request, markerSize: $markerSize);
48+
49+
$mapMarkerMarkup = <<<EOD
50+
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 100 100" width="{$markerSize}" height="{$markerSize}">
51+
<!--! Generated with MapMarker.io - https://mapmarker.io License - https://www.mapmarker.io/license -->
52+
<svg fill="{$backgroundIconColor}">
53+
{$backgroundIconMarkup}
54+
</svg>
55+
<svg fill="{$foregroundIconColor}" height="{$foregroundIconHeightPercent}%" x="{$foregroundIconXOffset}%" y="{$foregroundIconYOffset}%">
56+
{$foregroundIconMarkup}
57+
</svg>
58+
59+
{$labelMarkup}
60+
</svg>
61+
EOD;
62+
63+
return response($mapMarkerMarkup)->header('Content-Type', 'image/svg+xml');
64+
}
65+
}

resources/views/docs/versions.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<td class="text-green-400">Yes</td>
100100
<td class="text-green-400">Yes</td>
101101
<td class="text-green-400">Yes</td>
102-
<td class="text-orange-400">WIP</td>
102+
<td class="text-green-400">Yes</td>
103103
</tr>
104104
<tr>
105105
<td>Font-Awesome 4</td>

routes/web.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
// FONT-AWESOME 6
119119
Route::group(['prefix' => 'v6', 'namespace' => 'v6'], function () {
120120
Route::get('icon', 'IconController@show');
121-
// Route::get('pin', 'PinController@show');
121+
Route::get('pin', 'PinController@show');
122122
Route::get('icon-stack', 'IconStackController@show');
123123
});
124124
});

0 commit comments

Comments
 (0)