#!perl use strict; use warnings; use Test::More tests => 17; use Geo::Google::MapObject; use Test::Differences; use Test::JSON; use HTML::Template::Pluggable; use HTML::Template::Plugin::Dot; our $template =< Test TEST" width="" height=""/>
EOS ; { my $map = Geo::Google::MapObject->new ( key=>'api1', center=>'Berlin',zoom=>10,size=>"512x512"); ok($map, "map created"); ok($map->static_map_url eq "http://maps.google.com/maps/api/staticmap?center=Berlin&zoom=10&mobile=false&key=api1&sensor=false&size=512x512", "static_map_url"); ok($map->javascript_url eq "http://maps.google.com/maps?file=api&v=2&key=api1&sensor=false", "javascript_url"); is_json($map->json, '{"sensor":"false","zoom":"10","markers":[],"mobile":"false","center":"Berlin","size":{"width":"512","height":"512"}}', "json"); ok($map->width == 512, "width"); ok($map->height == 512, "height"); } { my $map = Geo::Google::MapObject->new ( key=>'api2', center=>'Berlin',zoom=>10, size=>"512x512"); my $t = HTML::Template::Pluggable->new(scalarref=>\$template, die_on_bad_params=>0); $t->param(map=>$map); my $output =< Test TEST EOS ; eq_or_diff($t->output, $output, "zero markers"); } { my $map = Geo::Google::MapObject->new ( key=>'api3', center=>'Berlin',zoom=>10, markers=>[{location=>'Zoo'},{location=>'Garten'},{location=>'Polizei'}], size=>"512x512"); my $t = HTML::Template::Pluggable->new(scalarref=>\$template, die_on_bad_params=>0); $t->param(map=>$map); my $output =< Test TEST
Zoo
Garten
Polizei
EOS ; eq_or_diff($t->output, $output, "location markers"); is_json($map->json, '{"zoom":"10","sensor":"false","markers":[{"location":"Zoo"},{"location":"Garten"},{"location":"Polizei"}],"mobile":"false","center":"Berlin","size":{"width":"512","height":"512"}}', "json"); } { my $map = Geo::Google::MapObject->new ( key=>'api4', center=>'Berlin',zoom=>10, markers=>[{location=>'Zoo',label=>'Z'},{location=>'Garten',label=>'G'},{location=>'Polizei',label=>'P'}], size=>"512x512"); my $t = HTML::Template::Pluggable->new(scalarref=>\$template, die_on_bad_params=>0); $t->param(map=>$map); my $output =< Test TEST
Zoo
Garten
Polizei
EOS ; eq_or_diff($t->output, $output, "label markers"); is_json($map->json, '{"zoom":"10","sensor":"false","markers":[{"location":"Zoo","label":"Z"},{"location":"Garten","label":"G"},{"location":"Polizei","label":"P"}],"mobile":"false","center":"Berlin","size":{"width":"512","height":"512"}}', "json"); } { my $map = Geo::Google::MapObject->new ( key=>'api5', center=>'Berlin',zoom=>10, markers=>[{location=>'Zoo',color=>'red'},{location=>'Garten',color=>'red'},{location=>'Polizei',color=>'green'}], size=>"512x512"); my $t = HTML::Template::Pluggable->new(scalarref=>\$template, die_on_bad_params=>0); $t->param(map=>$map); my $output =< Test TEST
Zoo
Garten
Polizei
EOS ; eq_or_diff($t->output, $output, "label markers"); is_json($map->json, '{"zoom":"10","sensor":"false","markers":[{"color":"red","location":"Zoo"},{"color":"red","location":"Garten"},{"color":"green","location":"Polizei"}],"mobile":"false","center":"Berlin","size":{"width":"512","height":"512"}}', "json"); } { my $map = Geo::Google::MapObject->new ( key=>'api6', center=>'Berlin',zoom=>10, markers=>[{location=>'Zoo',color=>'red',size=>'tiny'},{location=>'Garten',color=>'red',size=>'small'},{location=>'Polizei',color=>'green'}], size=>"512x512"); my $t = HTML::Template::Pluggable->new(scalarref=>\$template, die_on_bad_params=>0); $t->param(map=>$map); my $output =< Test TEST
Zoo
Garten
Polizei
EOS ; eq_or_diff($t->output, $output, "label markers"); is_json($map->json, '{"zoom":"10","sensor":"false","markers":[{"color":"red","location":"Zoo","size":"tiny"},{"color":"red","location":"Garten","size":"small"},{"color":"green","location":"Polizei"}],"mobile":"false","center":"Berlin","size":{"width":"512","height":"512"}}', "json"); } { my $map = Geo::Google::MapObject->new (hl=>'de', key=>'api7', center=>'Berlin',zoom=>10, markers=>[{location=>'Zoo',color=>'red',size=>'tiny'},{location=>'Garten',color=>'red',size=>'small'},{location=>'Polizei',color=>'green'},{location=>'Schloß',color=>'green'}], size=>"512x512"); my $t = HTML::Template::Pluggable->new(scalarref=>\$template, die_on_bad_params=>0); $t->param(map=>$map); my $output =< Test TEST
Zoo
Garten
Polizei
Schloß
EOS ; eq_or_diff($t->output, $output, "label markers"); is_json($map->json, '{"zoom":"10","sensor":"false","mobile":"false","center":"Berlin","size":{"width":"512","height":"512"},"hl":"de","markers":[{"color":"red","location":"Zoo","size":"tiny"},{"color":"red","location":"Garten","size":"small"},{"color":"green","location":"Polizei"},{"color":"green","location":"Schloß"}]}', "json"); }