css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

#map {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;

#geocodeError {
    position: absolute;
    display: none;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    padding: 25px;
    width: 250px;
    height: 150px;
    background: #fff;
    border: 2px solid #000;   
    font-weight: bold;
    font-size: 1.1em;
    text-align: center;
    z-index: 2000;

#errorCloseBtn {
    position: absolute;
    padding: 8px;    
    top: 2px;
    right: 4px;
    font-weight: bold;
    font-size: 0.96em;

#errorText {
    margin-top: 30px;
              'use strict';

// create geocode error box element
var geocodeErEl = document.createElement('div');
geocodeErEl.setAttribute('id', 'geocodeError');
// create close button for error box
var geocoderErCloseEl = document.createElement('input');
geocoderErCloseEl.setAttribute('value', 'X');
// create paragraph element to contain error text
var geocodeErTextEl = document.createElement('p');
// append elements to geocode error div
// append elememnts to map

// Map
var map = L.map('map', {
   center: [40.15, -77.25],
   zoom: 10,               

// Open Street Map 
var osm = L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&#169; <a href="//www.openstreetmap.org/">OpenStreetMap</a> contributors, CC BY-SA license'

// container for address search results
var addressSearchResults = new L.LayerGroup().addTo(map);

/*** Geocoder ***/
// OSM Geocoder
var osmGeocoder = new L.Control.OSMGeocoder({
    collapsed: false,
    position: 'topright',
    text: 'Search',
    placeholder: 'Enter address',    
    callback: function(results) {
            // error box element
            var geocodeErrorBox = jQuery('#geocodeError');
            var geocodeErrorText = jQuery('#errorText');
            // close error box if it is open
            if (!geocodeErrorBox.css('display','none')) {
            // If no results are found, add a message to the screen
            if (results.length == 0) {
				// placeholder="" is key to selecting DOM element
                var searchText = jQuery('.leaflet-control-geocoder-form input[placeholder="Enter address"]').val();
                // get search text or result text and put that in box
                geocodeErrorText.html('No results found for ' + searchText);
            // clear previous geocode results
            // create icon for result
            var addressSearchIcon = L.AwesomeMarkers.icon({
                icon: 'map',
                prefix: 'fa',
                markerColor: 'orange',
                iconColor: '#fff'
            // get coordinates for result
            var coords = L.latLng(results[0].lat,results[0].lon);
            // create a marker for result
            var marker = L.marker(coords, {
                icon: addressSearchIcon
            // add result object to map and zoom to 
            // open pop-up for location
            var popup = L.popup({closeOnClick: true}).setLatLng(coords).setContent(results[0].display_name).openOn(map);

// add event listener to click event for error message close button
jQuery('#errorCloseBtn').click(function() {
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................