jqueryui
4 years ago
select2
6 years ago
validation
2 years ago
wp-color-picker-alpha
5 years ago
autocomplete.js
6 years ago
autosave.js
7 years ago
button-group.js
3 years ago
clone.js
3 years ago
color.js
3 years ago
date.js
3 years ago
datetime.js
3 years ago
file-input.js
4 years ago
file-upload.js
4 years ago
file.js
3 years ago
image-advanced.js
4 years ago
image-select.js
6 years ago
image-upload.js
4 years ago
input-list.js
3 years ago
map-frontend.js
4 years ago
map.js
4 years ago
media.js
3 years ago
modal.js
2 years ago
notification.js
6 years ago
oembed.js
2 years ago
osm-frontend.js
5 years ago
osm.js
2 years ago
post.js
3 years ago
range.js
4 years ago
script.js
3 years ago
select-advanced.js
3 years ago
select-tree.js
5 years ago
select.js
3 years ago
slider.js
6 years ago
taxonomy.js
3 years ago
time.js
6 years ago
user.js
3 years ago
validation.min.js
2 years ago
video.js
6 years ago
wysiwyg.js
2 years ago
osm-frontend.js
52 lines
| 1 | jQuery( function( $ ) { |
| 2 | 'use strict'; |
| 3 | |
| 4 | /** |
| 5 | * Display Open Street Map |
| 6 | */ |
| 7 | function displayMap() { |
| 8 | var osmTileLayer = L.tileLayer( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { |
| 9 | attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' |
| 10 | } ); |
| 11 | var options = $( this ).data( 'osm_options' ), |
| 12 | mapOptions = options.js_options, |
| 13 | center = L.latLng( options.latitude, options.longitude ), |
| 14 | map; |
| 15 | |
| 16 | mapOptions.center = center; |
| 17 | |
| 18 | // Typcast zoom to a number |
| 19 | mapOptions.zoom *= 1; |
| 20 | |
| 21 | map = L.map( this, mapOptions ); |
| 22 | map.addLayer( osmTileLayer ); |
| 23 | |
| 24 | // Set marker |
| 25 | if ( options.marker ) { |
| 26 | var markerOptions = {}; |
| 27 | |
| 28 | // Set marker title |
| 29 | if ( options.marker_title ) { |
| 30 | markerOptions.title = options.marker_title; |
| 31 | } |
| 32 | |
| 33 | // Set marker icon |
| 34 | if ( options.marker_icon ) { |
| 35 | markerOptions.icon = L.icon( { |
| 36 | iconUrl: options.marker_icon |
| 37 | } ); |
| 38 | } |
| 39 | |
| 40 | var marker = L.marker( center, markerOptions ).addTo( map ) |
| 41 | } |
| 42 | |
| 43 | // Set info window |
| 44 | if ( options.info_window ) { |
| 45 | marker.bindPopup( options.info_window ).openPopup(); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | // Loop through all map instances and display them |
| 50 | $( '.rwmb-osm-canvas' ).each( displayMap ); |
| 51 | } ); |
| 52 |