payprop / html-googlemaps-v3

Fork of HTML::GoogleMaps to fix issues
2 stars 1 forks source link

api_key not passwd to G:C:G #8

Closed nigelhorne closed 7 years ago

nigelhorne commented 7 years ago

This line in the constructor:

geocoder => Geo::Coder::Google->new,

doesn't pass api_key to G:C:G.

I suggest something like:

sub new {
    my ( $class,%opts ) = @_;

    my $gc;
    if($opts{'api_key'}) {
        $gc = Geo::Coder::Google->new(key => $opts{'api_key'}, apidriver => 3);
   } else {
        $gc = Geo::Coder::Google->new(apidriver => 3);
   }

    return bless( {
        %opts,
        points     => [],
        poly_lines => [],
        geocoder  => $gc,
    }, $class );
}
leejo commented 7 years ago

Again, I'm going to say "patches welcome" on this one. Thanks!

nigelhorne commented 7 years ago

I believe you should be able to use the code I submitted at as a drop-in replacement for "new()".

leejo commented 7 years ago

I believe you should be able to use the code I submitted at as a drop-in replacement for "new()".

Can you submit a pull-request for this?

nigelhorne commented 7 years ago

Let me try, I've never done one before so let's give it a go :-)

leejo commented 7 years ago

Let me try, I've never done one before so let's give it a go :-)

Thanks!