Skip to content

Commit

Permalink
bump version; renamed fit_markers to fitbounds for consistency; brand…
Browse files Browse the repository at this point in the history
… new description in readme.txt
  • Loading branch information
bozdoz committed Jan 4, 2019
1 parent 5968ed0 commit 80ac9e9
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ However, you can also just give it an address, and the chosen geocoder (default:
| `zoom` | 12 |
| `height` | 250 |
| `width` | 100% |
| `fit_markers` | 0 (false) |
| `fitbounds` | 0 (false) |
| `zoomcontrol` | 0 (false) |
| `scrollwheel` | 0 (false) |
| `doubleclickzoom` | 0 (false) |
Expand Down Expand Up @@ -127,7 +127,7 @@ Then in the console, check the coordinates when you move the marker (should only
| `zoom` | 12 |
| `height` | 250 |
| `width` | 100% |
| `fit_markers` | 0 (false) |
| `fitbounds` | 0 (false) |
| `zoomcontrol` | 0 (false) |
| `scrollwheel` | 0 (false) |
| `doubleclickzoom` | 0 (false) |
Expand Down
2 changes: 1 addition & 1 deletion class.plugin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function __construct()
'default' => '0',
'type' => 'checkbox',
'helptext' => sprintf(
'%1$s %2$s <br /> <code>[leaflet-map fit_markers="1"]</code>',
'%1$s %2$s <br /> <code>[leaflet-map fitbounds]</code>',
__('If enabled, all markers on each map will alter the view of the map; i.e. the map will fit to the bounds of all of the markers on the map.', 'leaflet-map'),
$foreachmap
)
Expand Down
4 changes: 2 additions & 2 deletions leaflet-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Author URI: https://twitter.com/bozdoz/
* Text Domain: leaflet-map
* Domain Path: /languages/
* Version: 2.11.5
* Version: 2.12.0
* License: GPL2
* Leaflet Map is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -29,7 +29,7 @@
exit;
}

define('LEAFLET_MAP__PLUGIN_VERSION', '2.11.5');
define('LEAFLET_MAP__PLUGIN_VERSION', '2.12.0');
define('LEAFLET_MAP__PLUGIN_FILE', __FILE__);
define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__));

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "leaflet-map",
"version": "2.11.5",
"version": "2.12.0",
"description": "Leaflet Map WordPress Plugin",
"main": "index.js",
"scripts": {
Expand Down
73 changes: 56 additions & 17 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Contributors: bozdoz, Remigr, nielsalstrup, jeromelebleu, gerital, peteruithoven
Donate link: https://www.paypal.me/bozdoz
Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
Requires at least: 3.0.1
Tested up to: 5.0
Version: 2.11.5
Stable tag: 2.11.5
Tested up to: 5.0.2
Version: 2.12.0
Stable tag: 2.12.0
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -20,41 +20,70 @@ Add a map generated with [LeafletJS](http://leafletjs.com/): an open-source Java

= Maps =

Height, width, latitude, longitude and zoom are the basic attributes:
Simply create a **map** with:

`[leaflet-map height=250 width=250 lat=44.67 lng=-63.61 zoom=5]`
`[leaflet-map]`

However, you can also just give it an **address**, and Google (by default) will look it up for you:
Lookup an address with:

`[leaflet-map address="Oslo, Norway"]`
`[leaflet-map address="chicago"]`

The default URL requires attribution by its terms of use. If you want to change the URL, you may define a new attribution, or remove the attribution. You can define this site-wide in the admin, or you can set this per map in the shortcode (0 for disabled):
Know the latitude and longitude of a location? Use them (and a zoom level) with:

`[leaflet-map attribution=0]`
`[leaflet-map lat=44.67 lng=-63.61 zoom=5]`

OR
Add a **marker** under your map shortcode, like so:

`[leaflet-map attribution="Copyright @bozdoz"]`
`
[leaflet-map]
[leaflet-marker]
`

Look at other examples on the Shortcode Helper in the Leaflet Map admin section.
Want more? Make more (and fit the map to contain all of them):

= Markers =
`
[leaflet-map fitbounds]
[leaflet-marker address="tokyo"]
[leaflet-marker address="oslo"]
[leaflet-marker address="cairo"]
[leaflet-marker address="toronto"]
`

Add a marker to any map by adding `[leaflet-marker]` after any `[leaflet-map]` shortcode. You can adjust the lat/lng in the same way, as well as some other basic functionality (popup message, draggable, visible on load). Also, if you want to add a link to a marker popup, use this syntax: `[leaflet-marker]Message here: click here[/leaflet-marker]` and add a link like you normally would with the WordPress editor.
You can even add **popups** (to any shape) with their names:

= Lines and other Shapes =
`
[leaflet-map fitbounds]
[leaflet-marker address="tokyo"]Tokyo[/leaflet-marker]
[leaflet-marker address="oslo"]Oslo[/leaflet-marker]
...
`

Add a link to the popup messages the same way you would add any other link with the WordPress editor.

= Other Shapes, GeoJSON, and KML =

Add a line to the map by adding `[leaflet-line]`. You can specify the postions with a list separated by semi-colon `;` or bar `|` using lat/lng: `[leaflet-line latlngs="41, 29; 44, 18"]` or addresses: `[leaflet-line addresses="Istanbul; Sarajevo"]`, or x/y coordinates for image maps.

Add a circle to the map by adding `[leaflet-circle]`. You can specify the position using `lat` and `lng` and the radius in meters using `radius`. You can also customize the style using [Leaflet's Path options](https://leafletjs.com/reference-1.3.4.html#path-option). Example: `[leaflet-circle message="max distance" lng=5.117909610271454 lat=52.097914814706094 radius=17500 color="#0DC143" fillOpacity=0.1]`.

Or you can add a geojson shape via a url (work in progress): `[leaflet-geojson src="https://example.com/path/to.geojson"]`
Or you can add a geojson shape via a url (make sure you are allowed to access it if it's not hosted on your own server): `[leaflet-geojson src="https://example.com/path/to.geojson"]`. Add custom popups with field names; try out the default src file and fields like so (note fitbounds needs to be on leaflet-geojson (for now)):

`
[leaflet-map]
[leaflet-geojson fitbounds]{name}[/leaflet-geojson]
`

`name` is a property on that GeoJSON, and it can be accessed with curly brackets and the property name.

= Image Maps =

Alternatively, you could use a plain image for visitors to zoom and pan around with `[leaflet-image src="path/to/image/file.jpg"]`. See screenshots 3 - 5 for help setting that up.

Check out the source code on [GitHub](https://github.com/bozdoz/wp-plugin-leaflet-map)!
= More =

Check out other examples on the Shortcode Helper page in the Leaflet Map admin section.

Check out the **source code** and **more** details on [GitHub](https://github.com/bozdoz/wp-plugin-leaflet-map)!

Shoot me a question [@bozdoz](https://www.twitter.com/bozdoz/).

Expand Down Expand Up @@ -126,6 +155,13 @@ Yes: use the keyword `attribution` in your shortcode (semi-colon separated list

== Changelog ==

= 2.12.0 =
* Re-added Google Geocoder (optional), since they forced billing accounts
* Fixed links in shortcode helper page
* Fixed issue with marker popups that had single quotes
* Loading leaflet scripts and styles only when a map shortcode is used
* Added fitbounds to leaflet-map (to replace fit_markers someday)

= 2.11.5 =
* Added assumed-boolean attributes to all shortcodes; ex: `[leaflet-marker draggable svg]` would be the same as `[leaflet-marker draggable=1 svg=1]`

Expand Down Expand Up @@ -302,6 +338,9 @@ Yes: use the keyword `attribution` in your shortcode (semi-colon separated list

== Upgrade Notice ==

= 2.12.0 =
Fixed links in shortcode helper page; fixed issue with marker popups that had single quotes; loading leaflet scripts and styles only when a map shortcode is used

= 2.11.4 =
Fix to a race condition issue with custom scripts changing leaflet rendering methods

Expand Down
2 changes: 1 addition & 1 deletion scripts/construct-leaflet-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
mg.timeout = null;

// custom attribute
if (map.fit_markers) {
if (map._shouldFitBounds) {
mg.on('layeradd', function (d) {
// needs a timeout so that it doesn't
// opt out of a bound change
Expand Down
4 changes: 2 additions & 2 deletions shortcodes/class.image-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ class="leaflet-map"
map = L.map('leaflet-map-image-<?php echo $this->map_id; ?>', options).setView([0, 0], zoom);
// make it known that it is an image map
map.is_image_map = true;
if (<?php echo $fit_markers; ?>) {
map.fit_markers = true;
if (<?php echo $fitbounds; ?>) {
map._shouldFitBounds = true;
}
<?php
if ($attribution) {
Expand Down
10 changes: 8 additions & 2 deletions shortcodes/class.map-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ protected function getAtts($atts='')
$scrollwheel : $settings->get('scroll_wheel_zoom');
$atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ?
$doubleclickzoom : $settings->get('double_click_zoom');

// backwards-compatible fit_markers
$atts['fit_markers'] = array_key_exists('fit_markers', $atts) ?
$fit_markers : $settings->get('fit_markers');

// fitbounds is what it should be called @since v2.12.0
$atts['fitbounds'] = array_key_exists('fitbounds', $atts) ?
$fitbounds : $atts['fit_markers'];

/* allow percent, but add px for ints */
$atts['height'] .= is_numeric($atts['height']) ? 'px' : '';
$atts['width'] .= is_numeric($atts['width']) ? 'px' : '';
Expand Down Expand Up @@ -238,8 +244,8 @@ class="leaflet-map"
.setView([<?php
echo $lat . ',' . $lng . '],' . $zoom;
?>);
if (<?php echo $fit_markers; ?>) {
map.fit_markers = true;
if (<?php echo $fitbounds; ?>) {
map._shouldFitBounds = true;
}
<?php
if ($attribution) :
Expand Down

0 comments on commit 80ac9e9

Please sign in to comment.