The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Imager::Bing::MapLayer - create a map layer for Bing Maps

SYNOPSIS

    my $layer = Imager::Bing::MapLayer->new(
      base_dir           => $dir,     # base directory (default '.')
      overwrite          => 1,        # overwrite existing (default)
      autosave           => 1,        # save on exit (default)
      in_memory          => 0,        # keep tiles in memory (default false)
      min_level          => 1,        # min zoom level (default)
      max_level          => 19,       # max zoom level (default)
      combine            => 'darken', # tile composition method (default)
    );

    # Plot polygons (e.g. geographic boundaries)

    $layer->polygon(
       points => $points,                  # listref to [ lat, lon ] points
       fill   => Imager::Fill->new( ... ), #
    );

    # Plot greyscale gradient circles for heatmaps

    $layer->radial_circle(
        r      => 100,              # radius in meters
        -min_r => 1,                # minimum pixel radius for any zoom level
        x      => $longitude,       # longitude (x = east-west)
        y      => $latitude,        # latitude  (y = north-south)
    );

    # Blur filter

    $layer->filter( type => 'gaussian', stddev => 1 );

    # Colourise greyscale heatmaps

    $layer->colourise();

DESCRIPTION

This module is a wrapper around the Imager::Draw module, which allows you to create Bing map layers using longitude and latitude coordinates.

The module will automatically map them to the appropriate points on tile files.

ATTRIBUTES

base_dir

The base directory to save tile files in.

in_memory

The timeout for how many seconds a tile is kept in memory.

When a tile is timed out, it is saved to disk after each Imager drawing operation, and reloaded if it is later needed.

centroid_latitude

This is the default latitude for translating points to pixels. Generally you don't need to worry about this.

centroid_longitude

This is the default longitude for translating points to pixels. Generally you don't need to worry about this.

overwrite

When true (default), existing tiles will be overwritten rather than edited.

Be wary of editing existing tiles, since antialiased lines and opaque fills will darken existing points rather than drawing over them.

autosave

When true (default), tiles will be automatically saved.

Alternatively, you can use the "save" method.

combine

The tile combination method. It defaults to darken.

tile_class

The base class used for tiles.

METHODS

levels

  my @levels = @{ $layer->levels };

This returns a reference to a list of Imager::Bing::MapLayer::Level objects.

min_level

The minimum zoom level to generate.

max_level

The maximum zoom level to generate.

radial_circle

    $layer->radial_circle(
        r      => $radius_in_meters,
        -min_r => $min_radius_in_pixels,
        x      => $longitude,
        y      => $latitude,
    );

This method plots "fuzzy" greyscale circles, which are intended to be used for heatmaps. The radius is scaled appropriately for each zoom level in the layer.

If -min_r is specified, then a circle will always be drawn with that minimum radius: this ensures that lower zoom levels will always have a point plotted.

colourise

    $layer->colourise();

The method colourises greyscale layers. It is intended to be used for heatmaps generated using the "radial_circle" method.

filter

    $layer->filter( type => 'gaussian', stddev => 1 );

This applies Imager::Filters to every tile on every zoom level of the layer.

Be aware that some filter effects may enhance the edges of tiles in each zoom level.

setpixel

Draw a pixel at a specific latitude and longitude coordinate.

See the corresponding method in Imager::Draw for more information.

line

Draw a line between two coordinates.

See the corresponding method in Imager::Draw for more information.

box

Draw a box bounded by northwest and southeast coordinates.

See the corresponding method in Imager::Draw for more information.

polyline

Draw a polyline for a set of coordinates.

Note that a polyline is not closed. To draw a closed area, use the "polygon" method.

See the corresponding method in Imager::Draw for more information.

polygon

Draw a closed polygon for a set of coordinates.

See the corresponding method in Imager::Draw for more information.

arc

Draw an arc.

See the corresponding method in Imager::Draw for more information.

circle

Draw a circle.

See the corresponding method in Imager::Draw for more information.

string

Draw a text string.

TODO - the size is not scaled.

See the corresponding method in Imager::Draw for more information.

align_string

Draw an aligned text string.

TODO - the size is not scaled.

See the corresponding method in Imager::Draw for more information.

save

Save the tiles.

KNOWN ISSUES

For plotting very large polylines and polygons, the system will die with no error message.

SEE ALSO

AUTHOR

Robert Rothenberg, <rrwo at cpan.org>

BUGS

Please report any bugs or feature requests to the author, or through the web interface at https://github.com/robrwo/Imager-Bing-MapLayer/issues.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Imager::Bing::MapLayer

You can also look for information at:

ACKNOWLEDGEMENTS

  • Foxtons, Ltd.

LICENSE AND COPYRIGHT

Copyright 2013-2014 Robert Rothenberg.

This program is released under the following license: atistic2