Skip to content

Commit

Permalink
Merge pull request bozdoz#195 from hupe13/master
Browse files Browse the repository at this point in the history
Resolves a few issues
  • Loading branch information
hupe13 authored Dec 29, 2022
2 parents fa44006 + bbfdd83 commit 858ca5a
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Add a popup to the line by adding text to the content of the shortcode:
| `addresses`, `latlngs`, or `coordinates` | For geocoded addresses, latitude/longitude, or x/y coordinates for Image Maps; ex: `[leaflet-line latlngs="41, 29; 44, 18"]` or addresses: `[leaflet-line addresses="Istanbul; Sarajevo"]` |
| `fitbounds` | Fit the map to the bounds of the line (instead of whatever center you gave the map originally) |

And the following Shape Options. See https://leafletjs.com/reference-1.3.4.html#path for details.
And the following Shape Options. See https://leafletjs.com/reference.html#path for details.
'stroke', 'color', 'weight', 'opacity',
'lineCap', 'lineJoin', 'dashArray', 'dashOffset'
'fill', 'fillColor', 'fillOpacity', 'fillRule', 'className'
Expand All @@ -248,7 +248,7 @@ Add a circle to the map by adding `[leaflet-circle]`. You can specify the positi
| `fitbounds` | Fit the map to the bounds of the circle (instead of whatever center you gave the map originally) |
| radius | Radius of the circle in meters |

Includes all style options: See https://leafletjs.com/reference-1.3.4.html#path
Includes all style options: See https://leafletjs.com/reference.html#path

---

Expand Down Expand Up @@ -279,7 +279,7 @@ Or you can add a geojson shape via a url:
| `popupanchor` | Set the anchor position of the popup: e.g. "40,60" for 40px left 60px top |
| `tooltipanchor` | Set the anchor position of the tooltip: e.g. "40,60" for 40px left 60px top |

Includes all style options: See https://leafletjs.com/reference-1.3.4.html#path. Also, if you want to add feature
Includes all style options: See https://leafletjs.com/reference.html#path. Also, if you want to add feature
properties to the popups, use the inner content and curly brackets to substitute the values:
`[leaflet-geojson]Field A = {field_a}[/leaflet-geojson]`.

Expand Down
14 changes: 9 additions & 5 deletions class.geocoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ private function osm_geocode ( $address ) {
$geocode_url .= $address;
$json = $this->get_url($geocode_url);
$json = json_decode($json);

return (Object) array(
'lat' => $json[0]->lat,
'lng' => $json[0]->lon,
);

if (isset($json[0]->lat) && isset($json[0]->lon)) {
return (Object) array(
'lat' => $json[0]->lat,
'lng' => $json[0]->lon,
);
} else {
return false;
}
}

/**
Expand Down
7 changes: 6 additions & 1 deletion class.plugin-option.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function __construct($details = array())
'display_name' => FILTER_SANITIZE_STRING,
'default' => null,
'type' => FILTER_SANITIZE_STRING,
'min' => "",
'max' => "",
'step' => "",
'options' => array(
'filter' => FILTER_SANITIZE_STRING,
'flags' => FILTER_FORCE_ARRAY
Expand Down Expand Up @@ -111,7 +114,9 @@ class="full-width"
?>
<input
class="full-width"
step="any"
min="<?php echo isset($this->min) ? $this->min : ""; ?>"
max="<?php echo isset($this->max) ? $this->max : ""; ?>"
step="<?php echo isset($this->step) ? $this->step : "any"; ?>"
name="<?php echo $name; ?>"
type="<?php echo $this->type; ?>"
id="<?php echo $name; ?>"
Expand Down
9 changes: 9 additions & 0 deletions class.plugin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ private function __construct()
'display_name'=>__('Default Zoom', 'leaflet-map'),
'default'=>'12',
'type' => 'number',
'min' => 0,
'max' => 20,
'step' => 1,
'helptext' => sprintf(
'%1$s %2$s <br /> <code>[leaflet-map zoom="5"]</code>',
__('Default zoom for maps.', 'leaflet-map'),
Expand Down Expand Up @@ -171,6 +174,9 @@ private function __construct()
'display_name'=>__('Default Min Zoom', 'leaflet-map'),
'default' => '0',
'type' => 'number',
'min' => 0,
'max' => 20,
'step' => 1,
'helptext' => sprintf(
'%1$s %2$s <br /> <code>[leaflet-map min_zoom="1"]</code>',
__('Restrict the viewer from zooming in past the minimum zoom. Can set per map in shortcode or adjust for all maps here.', 'leaflet-map'),
Expand All @@ -181,6 +187,9 @@ private function __construct()
'display_name'=>__('Default Max Zoom', 'leaflet-map'),
'default' => '19',
'type' => 'number',
'min' => 0,
'max' => 20,
'step' => 1,
'helptext' => sprintf(
'%1$s %2%s <br /> <code>%3$s</code>',
__('Restrict the viewer from zooming out past the maximum zoom. Can set per map in shortcode or adjust for all maps here', 'leaflet-map'),
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Contributors: bozdoz, remigr, gerital, sal0max, thibault-barrat
Donate link: https://www.paypal.me/bozdoz
Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
Requires at least: 4.6
Tested up to: 6.0.2
Tested up to: 6.1
Version: 3.0.5
Stable tag: 3.0.5
License: GPLv2
Expand Down Expand Up @@ -64,7 +64,7 @@ Add a link to the popup messages the same way you would add any other link with

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]`.
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.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 (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:

Expand Down
4 changes: 2 additions & 2 deletions scripts/shortcode-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
function update_marker() {
var latlng = marker_1.getLatLng();
marker_input.value =
'[leaflet-marker lat=' + latlng.lat + ' lng=' + latlng.lng + ']';
'[leaflet-marker lat=' + latlng.lat + ' lng=' + latlng.lng + ']'.__('My Marker', 'leaflet-map').'[/leaflet-marker]';
}

function update_map() {
Expand All @@ -24,7 +24,7 @@
latlng.lng +
' zoom=' +
map_1.getZoom() +
']';
']'.__('My Marker', 'leaflet-map').'[/leaflet-marker]';

// update marker if outside of bounds
if (!bounds.contains(marker_1.getLatLng())) {
Expand Down
6 changes: 3 additions & 3 deletions shortcodes/class.map-shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ protected function getHTML($atts='', $content=null)
$settings = Leaflet_Map_Plugin_Settings::init();

// map uses lat/lng
$lat = empty($lat) ? $settings->get('default_lat') : $lat;
$lng = empty($lng) ? $settings->get('default_lng') : $lng;
$lat = isset($lat) ? $lat : $settings->get('default_lat');
$lng = isset($lng) ? $lng : $settings->get('default_lng');

// validate lat/lng
$lat = $this->LM->filter_float($lat);
Expand Down Expand Up @@ -296,7 +296,7 @@ protected function getHTML($atts='', $content=null)
/* should be iterated for multiple maps */
ob_start();
?>/*<script>*/
var baseUrl = '<?php echo filter_var($tileurl, FILTER_SANITIZE_URL); ?>';
var baseUrl = atob('<?php echo base64_encode(filter_var($tileurl, FILTER_SANITIZE_URL)); ?>');
var base = (!baseUrl && window.MQ) ?
window.MQ.mapLayer() : L.tileLayer(baseUrl,
L.Util.extend({}, {
Expand Down

0 comments on commit 858ca5a

Please sign in to comment.