Skip to content

Porting code from Google API requires calculating zoom and center parameters #4

@mrdvt92

Description

@mrdvt92

I'm trying to port some code from the old Google API to your docker which uses the Perl package Geo::Google::StaticMaps::V2. The issue is that both center and zoom parameters are required for your API but, they were not required for the Google API. I request that you add the business logic to calculate reasonable defaults when not specified.

  • To calculate a reasonable center, it could use the average of the bounding box e.g. avg(min(lat), max(lat)), avg(min(lon), max(lon))
  • To calculate a reasonable zoom, from the bounding box, you might be able to reverse this process discussed at Stack Overflow

An example with hard coded zoom and center.

perl -MGeo::Google::StaticMaps::V2 -E '
my $lat  = shift || 38.780676;
my $lon  = shift || -77.387105;
my $zoom = shift || 14;
my $map  = Geo::Google::StaticMaps::V2->new(server=>"localhost:3000", script=>"/map.png");
$map->marker(location=>{lat=>$lat, lon=>$lon});
$map->center(join(",", $lat, $lon));
$map->zoom($zoom);
say $map->url;
'

Returns: http://localhost:3000/map.png?size=600x400&sensor=false&markers=38.780676%2C-77.387105&center=38.780676%2C-77.387105&zoom=14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions