File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Embed \Adapters ;
4+
5+ use Embed \Request ;
6+ use Embed \Utils ;
7+
8+ /**
9+ * Adapter to get the embed code from cartodb.
10+ */
11+ class Cartodb extends Webpage implements AdapterInterface
12+ {
13+ /**
14+ * {@inheritdoc}
15+ */
16+ public static function check (Request $ request )
17+ {
18+ return $ request ->isValid () && $ request ->match ([
19+ 'https://*.cartodb.com/viz/*/public_map ' ,
20+ ]);
21+ }
22+
23+ /**
24+ * {@inheritdoc}
25+ */
26+ public function getCode ()
27+ {
28+ $ this ->width = null ;
29+ $ this ->height = 520 ;
30+
31+ $ url = $ this ->request ->createUrl ()->withDirectoryPosition (2 , 'embed_map ' )->getUrl ();
32+
33+ return Utils::iframe ($ url , '100% ' , $ this ->height );
34+ }
35+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class CartodbTest extends TestCaseBase
4+ {
5+ public function testOne ()
6+ {
7+ $ this ->assertEmbed (
8+ 'https://porcentua26j.cartodb.com/viz/ab0f51e6-3c16-11e6-b12e-0e5db1731f59 ' ,
9+ [
10+ 'title ' => 'Resultados 26J / 20Dj ' ,
11+ 'height ' => 520 ,
12+ 'type ' => 'rich ' ,
13+ 'code ' => '<iframe src="https://porcentua26j.cartodb.com/viz/ab0f51e6-3c16-11e6-b12e-0e5db1731f59/embed_map" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:100%;height:520px;"></iframe> ' ,
14+ 'providerName ' => 'CartoDB ' ,
15+ ]
16+ );
17+ }
18+ }
You can’t perform that action at this time.
0 commit comments