Plugin Directory

Changeset 1771879 for leaflet-map


Ignore:
Timestamp:
11/20/2017 11:03:44 PM (8 years ago)
Author:
bozdoz
Message:

v2.9 gpx shortcode

Location:
leaflet-map
Files:
2 added
3 deleted
6 edited
25 copied

Legend:

Unmodified
Added
Removed
  • leaflet-map/tags/2.9/class.leaflet-map.php

    r1712964 r1771879  
    4444            'file' => 'class.kml-shortcode.php',
    4545            'class' => 'Leaflet_Kml_Shortcode'
     46        ),
     47        'leaflet-gpx' => array(
     48            'file' => 'class.gpx-shortcode.php',
     49            'class' => 'Leaflet_Gpx_Shortcode'
    4650        ),
    4751        'leaflet-line' => array(
     
    178182       
    179183        // optional ajax geojson plugin
    180         wp_register_script('leaflet_ajax_geojson_js', plugins_url('scripts/leaflet-ajax-geojson.js', __FILE__), Array('leaflet_js',), self::$version, false);
    181 
    182184        wp_register_script('tmcw_togeojson', 'https://cdn.rawgit.com/mapbox/togeojson/master/togeojson.js', Array('jquery'), self::$version, false);
    183185
    184         wp_register_script('leaflet_ajax_kml_js', plugins_url('scripts/leaflet-ajax-kml.js', __FILE__), Array('tmcw_togeojson', 'leaflet_js', 'leaflet_ajax_geojson_js'), self::$version, false);
    185 
     186        wp_register_script('leaflet_ajax_geojson_js', plugins_url('scripts/leaflet-ajax-geojson.js', __FILE__), Array('tmcw_togeojson', 'leaflet_js'), self::$version, false);
     187       
    186188        /* run a construct function in the document head for subsequent functions to use (it is lightweight) */
    187189        wp_enqueue_script('leaflet_map_construct', plugins_url('scripts/construct-leaflet-map.js', __FILE__), Array(), self::$version, false);
  • leaflet-map/tags/2.9/leaflet-map.php

    r1720896 r1771879  
    66    Author: bozdoz
    77    Author URI: https://twitter.com/bozdoz/
    8     Version: 2.8.6
     8    Version: 2.9
    99    License: GPL2
    1010
  • leaflet-map/tags/2.9/readme.txt

    r1720896 r1771879  
    77Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
    88Requires at least: 3.0.1
    9 Tested up to: 4.8.1
    10 Version: 2.8.6
    11 Stable tag: 2.8.6
     9Tested up to: 4.9
     10Version: 2.9
     11Stable tag: 2.9
    1212License: GPLv2
    1313License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8080Yes, just give it a source URL: `[leaflet-geojson src="https://example.com/path/to.geojson"]` It will also support leaflet geojson styles or geojson.io styles. Add a popup message with `[leaflet-geojson popup_text="hello!"]`, or add HTML by adding it to the content of the shortcode: `[leaflet-geojson]<a href="#">Link here</a>[/leaflet-geojson]` or identify a geojson property with `popup_property`, and each shape will use its own popup text if available.
    8181
    82 = Can I add kml? =
    83 
    84 Sure!? Use the same attributes as leaflet-geojson (above), but use the `[leaflet-kml]` shortcode.
     82= Can I add kml/gpx? =
     83
     84Sure!? Use the same attributes as leaflet-geojson (above), but use the `[leaflet-kml]` or `[leaflet-gpx]` shortcode.
    8585
    8686= Can I add a message to a marker? =
     
    122122
    123123= 2.8.6 =
     124* Added [leaflet-gpx] for GPX format
     125
     126= 2.8.6 =
    124127* Fix image shortcode ratio
    125128
     
    262265
    263266= 2.8.6 =
     267Added [leaflet-gpx] for GPX format
     268
     269= 2.8.6 =
    264270Fix image shortcode ratio
    265271
  • leaflet-map/tags/2.9/scripts/leaflet-ajax-geojson.js

    r1562379 r1771879  
    11L.AjaxGeoJSON = L.GeoJSON.extend({
    2     options : {},
     2    options : {
     3        type: 'json' // 'json|kml|gpx'
     4    },
    35
    46    initialize : function (url, options) {
     
    1012    onAdd : function (map) {
    1113        var _this = this,
     14            type = this.options.type,
    1215            xhr;
    1316
     
    2326                if (xhr.readyState === xhr.DONE &&
    2427                    xhr.status === 200) {
    25                     data = JSON.parse( xhr.responseText );
     28                    if (type === 'json') {
     29                        data = JSON.parse( xhr.responseText );
     30                    } else if (['kml', 'gpx'].indexOf(type) !== -1) {
     31                        data = window.toGeoJSON[ type ]( xhr.responseXML );
     32                    }
    2633                    _this.json = data;
    2734                    _this.layer.addData( data );
  • leaflet-map/tags/2.9/shortcodes/class.geojson-shortcode.php

    r1710942 r1771879  
    1616class Leaflet_Geojson_Shortcode extends Leaflet_Shortcode {
    1717    /**
    18     * @var string $wp_script to enqueue
    19     */
    20     public static $wp_script = 'leaflet_ajax_geojson_js';
    21     /**
    22     * @var string $L_method how leaflet renders the src
    23     */
    24     public static $L_method = 'ajaxGeoJson';
    25     /**
    2618    * @var string $default_src default src
    2719    */
    2820    public static $default_src = 'https://rawgit.com/bozdoz/567817310f102d169510d94306e4f464/raw/2fdb48dafafd4c8304ff051f49d9de03afb1718b/map.geojson';
     21
     22    /**
     23    * @var string $type how leaflet renders the src
     24    */
     25    public static $type = 'json';
    2926
    3027    protected function getHTML ($atts, $content) {
     
    3532        if ($atts) extract($atts);
    3633
    37         wp_enqueue_script( $class::$wp_script );
     34        wp_enqueue_script( 'leaflet_ajax_geojson_js' );
    3835
    3936        if ($content) {
     
    7673                        'stroke-width' : 'width',
    7774                    },
    78                     layer = L.<?php echo $class::$L_method; ?>(src, {
     75                    layer = L.ajaxGeoJson(src, {
     76                        type: '<?php echo $class::$type; ?>',
    7977                        style : layerStyle,
    8078                        onEachFeature : onEachFeature
  • leaflet-map/tags/2.9/shortcodes/class.kml-shortcode.php

    r1710942 r1771879  
    1616class Leaflet_Kml_Shortcode extends Leaflet_Geojson_Shortcode {
    1717    /**
    18     * @var string $wp_script to enqueue
     18    * @var string $type how leaflet renders the src
    1919    */
    20     public static $wp_script = 'leaflet_ajax_kml_js';
    21     /**
    22     * @var string $L_method how leaflet renders the src
    23     */
    24     public static $L_method = 'ajaxKML';
     20    public static $type = 'kml';
    2521    /**
    2622    * @var string $default_src default src
  • leaflet-map/trunk/class.leaflet-map.php

    r1712964 r1771879  
    4444            'file' => 'class.kml-shortcode.php',
    4545            'class' => 'Leaflet_Kml_Shortcode'
     46        ),
     47        'leaflet-gpx' => array(
     48            'file' => 'class.gpx-shortcode.php',
     49            'class' => 'Leaflet_Gpx_Shortcode'
    4650        ),
    4751        'leaflet-line' => array(
     
    178182       
    179183        // optional ajax geojson plugin
    180         wp_register_script('leaflet_ajax_geojson_js', plugins_url('scripts/leaflet-ajax-geojson.js', __FILE__), Array('leaflet_js',), self::$version, false);
    181 
    182184        wp_register_script('tmcw_togeojson', 'https://cdn.rawgit.com/mapbox/togeojson/master/togeojson.js', Array('jquery'), self::$version, false);
    183185
    184         wp_register_script('leaflet_ajax_kml_js', plugins_url('scripts/leaflet-ajax-kml.js', __FILE__), Array('tmcw_togeojson', 'leaflet_js', 'leaflet_ajax_geojson_js'), self::$version, false);
    185 
     186        wp_register_script('leaflet_ajax_geojson_js', plugins_url('scripts/leaflet-ajax-geojson.js', __FILE__), Array('tmcw_togeojson', 'leaflet_js'), self::$version, false);
     187       
    186188        /* run a construct function in the document head for subsequent functions to use (it is lightweight) */
    187189        wp_enqueue_script('leaflet_map_construct', plugins_url('scripts/construct-leaflet-map.js', __FILE__), Array(), self::$version, false);
  • leaflet-map/trunk/leaflet-map.php

    r1720896 r1771879  
    66    Author: bozdoz
    77    Author URI: https://twitter.com/bozdoz/
    8     Version: 2.8.6
     8    Version: 2.9
    99    License: GPL2
    1010
  • leaflet-map/trunk/readme.txt

    r1720896 r1771879  
    77Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive
    88Requires at least: 3.0.1
    9 Tested up to: 4.8.1
    10 Version: 2.8.6
    11 Stable tag: 2.8.6
     9Tested up to: 4.9
     10Version: 2.9
     11Stable tag: 2.9
    1212License: GPLv2
    1313License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8080Yes, just give it a source URL: `[leaflet-geojson src="https://example.com/path/to.geojson"]` It will also support leaflet geojson styles or geojson.io styles. Add a popup message with `[leaflet-geojson popup_text="hello!"]`, or add HTML by adding it to the content of the shortcode: `[leaflet-geojson]<a href="#">Link here</a>[/leaflet-geojson]` or identify a geojson property with `popup_property`, and each shape will use its own popup text if available.
    8181
    82 = Can I add kml? =
    83 
    84 Sure!? Use the same attributes as leaflet-geojson (above), but use the `[leaflet-kml]` shortcode.
     82= Can I add kml/gpx? =
     83
     84Sure!? Use the same attributes as leaflet-geojson (above), but use the `[leaflet-kml]` or `[leaflet-gpx]` shortcode.
    8585
    8686= Can I add a message to a marker? =
     
    122122
    123123= 2.8.6 =
     124* Added [leaflet-gpx] for GPX format
     125
     126= 2.8.6 =
    124127* Fix image shortcode ratio
    125128
     
    262265
    263266= 2.8.6 =
     267Added [leaflet-gpx] for GPX format
     268
     269= 2.8.6 =
    264270Fix image shortcode ratio
    265271
  • leaflet-map/trunk/scripts/leaflet-ajax-geojson.js

    r1562379 r1771879  
    11L.AjaxGeoJSON = L.GeoJSON.extend({
    2     options : {},
     2    options : {
     3        type: 'json' // 'json|kml|gpx'
     4    },
    35
    46    initialize : function (url, options) {
     
    1012    onAdd : function (map) {
    1113        var _this = this,
     14            type = this.options.type,
    1215            xhr;
    1316
     
    2326                if (xhr.readyState === xhr.DONE &&
    2427                    xhr.status === 200) {
    25                     data = JSON.parse( xhr.responseText );
     28                    if (type === 'json') {
     29                        data = JSON.parse( xhr.responseText );
     30                    } else if (['kml', 'gpx'].indexOf(type) !== -1) {
     31                        data = window.toGeoJSON[ type ]( xhr.responseXML );
     32                    }
    2633                    _this.json = data;
    2734                    _this.layer.addData( data );
  • leaflet-map/trunk/shortcodes/class.geojson-shortcode.php

    r1710942 r1771879  
    1616class Leaflet_Geojson_Shortcode extends Leaflet_Shortcode {
    1717    /**
    18     * @var string $wp_script to enqueue
    19     */
    20     public static $wp_script = 'leaflet_ajax_geojson_js';
    21     /**
    22     * @var string $L_method how leaflet renders the src
    23     */
    24     public static $L_method = 'ajaxGeoJson';
    25     /**
    2618    * @var string $default_src default src
    2719    */
    2820    public static $default_src = 'https://rawgit.com/bozdoz/567817310f102d169510d94306e4f464/raw/2fdb48dafafd4c8304ff051f49d9de03afb1718b/map.geojson';
     21
     22    /**
     23    * @var string $type how leaflet renders the src
     24    */
     25    public static $type = 'json';
    2926
    3027    protected function getHTML ($atts, $content) {
     
    3532        if ($atts) extract($atts);
    3633
    37         wp_enqueue_script( $class::$wp_script );
     34        wp_enqueue_script( 'leaflet_ajax_geojson_js' );
    3835
    3936        if ($content) {
     
    7673                        'stroke-width' : 'width',
    7774                    },
    78                     layer = L.<?php echo $class::$L_method; ?>(src, {
     75                    layer = L.ajaxGeoJson(src, {
     76                        type: '<?php echo $class::$type; ?>',
    7977                        style : layerStyle,
    8078                        onEachFeature : onEachFeature
  • leaflet-map/trunk/shortcodes/class.kml-shortcode.php

    r1710942 r1771879  
    1616class Leaflet_Kml_Shortcode extends Leaflet_Geojson_Shortcode {
    1717    /**
    18     * @var string $wp_script to enqueue
     18    * @var string $type how leaflet renders the src
    1919    */
    20     public static $wp_script = 'leaflet_ajax_kml_js';
    21     /**
    22     * @var string $L_method how leaflet renders the src
    23     */
    24     public static $L_method = 'ajaxKML';
     20    public static $type = 'kml';
    2521    /**
    2622    * @var string $default_src default src
Note: See TracChangeset for help on using the changeset viewer.