HTML-OSM
view release on metacpan or search on metacpan
[51.5074, -0.1278, 'London'],
],
zoom => 10,
);
Creates a new `HTML::OSM` object with the provided coordinates and optional zoom level.
- `cache`
A caching object.
If not provided,
an in-memory cache is created with a default expiration of one hour.
- `coordinates`
An array reference containing a list of coordinates.
Each entry should be an array with latitude, longitude, and an optional label, in the format:
[latitude, longitude, label, icon_url]
If latitude and/or longitude is undefined,
the label is taken to be a location to be added.
If no coordinates are provided, an error will be thrown.
- `config_file`
Points to a configuration file which contains the parameters to `new()`.
The file can be in any common format,
including `YAML`, `XML`, and `INI`.
This allows the parameters to be set at run time.
- `css_url`
Location of the CSS, default [https://unpkg.com/leaflet@1.9.4/dist/leaflet.css](https://unpkg.com/leaflet@1.9.4/dist/leaflet.css).
- `geocoder`
An optional geocoder object such as [Geo::Coder::List](https://metacpan.org/pod/Geo%3A%3ACoder%3A%3AList) or [Geo::Coder::Free](https://metacpan.org/pod/Geo%3A%3ACoder%3A%3AFree).
- `height`
Height (in pixels or using your own unit), the default is 400px.
- `js_url`
Location of the JavaScript, default [https://unpkg.com/leaflet@1.9.4/dist/leaflet.js](https://unpkg.com/leaflet@1.9.4/dist/leaflet.js).
- `min_interval`
Minimum number of seconds to wait between API requests.
Defaults to `0` (no delay).
Use this option to enforce rate-limiting.
- `ua`
An object to use for HTTP requests.
If not provided, a default user agent is created.
- `host`
The API host endpoint.
Defaults to [https://nominatim.openstreetmap.org/search](https://nominatim.openstreetmap.org/search).
- `width`
Width (in pixels or using your own unit), the default is 600px.
- zoom
An optional zoom level for the map, with a default value of 12.
## add\_marker
Add a marker to the map at the given point.
A point can be a unique place name, like an address,
an object that understands `latitude()` and `longitude()`,
or a pair of coordinates passed in as an arrayref: `[ longitude, latitude ]`.
Will return 0 if the point is not found and 1 on success.
It takes two optional arguments:
- html
Add a popup info window as well.
- icon
A url to the icon to be added.
## center
Center the map at a given point.
Returns 1 on success, 0 if the point could not be found.
## zoom
Get/set the new zoom level (0 is corsest)
$map->zoom(10);
## onload\_render
Renders the map and returns a two element list.
The first element needs to be placed in the head section of your HTML document.
The second in the body where you want the map to appear.
# AUTHOR
Nigel Horne, `<njh at nigelhorne.com>`
# BUGS
# SEE ALSO
- [https://wiki.openstreetmap.org/wiki/API](https://wiki.openstreetmap.org/wiki/API)
- [HTML::GoogleMaps::V3](https://metacpan.org/pod/HTML%3A%3AGoogleMaps%3A%3AV3)
Much of the interface to `HTML::OSM` mimicks this for compatibility.
- [https://leafletjs.com/](https://leafletjs.com/)
( run in 0.582 second using v1.01-cache-2.11-cpan-39bf76dae61 )