cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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>
<head>
	<title>Locate Me on the Map</title>

	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

  <!-- Load Leaflet CSS from CDN.  More info at: http://leafletjs.com/examples/quick-start.html-->
  <link rel="stylesheet" href="//cdn.jsdelivr.net/leaflet/0.7.3/leaflet.css" />

  <!-- Load the Leaflet from CDN. More info at: http://leafletjs.com/examples/quick-start.html-->
  <script src="//cdn.jsdelivr.net/leaflet/0.7.3/leaflet.js"></script>

 <!-- Load the Esri Leaflet plugin from CDN.  For more info: https://esri.github.io/esri-leaflet/examples/ -->
<script src="//cdn.jsdelivr.net/leaflet.esri/1.0.0/esri-leaflet.js"></script>

</head>
<body>
	<div id="map"></div>
</body>
</html>

            
          
!
            
              		body {
			padding: 0;
			margin: 0;
		}
		html, body, #map {
			height: 100%;
		}
            
          
!
            
              		//Check out more Sample code and API reference at https://esri.github.io/esri-leaflet/examples/

//Adds the map control and sets the center point to Durham and zoom scale to 10. For more info on the Leaflet map control check out: http://leafletjs.com/reference.html#map-class
var map = L.map('map').setView([35.9886, -78.9072], 10); //35.9886° N, 78.9072° W

//Adds a basemap to the map.  To see all the available basemaps: https://esri.github.io/esri-leaflet/api-reference/layers/basemap-layer.html
L.esri.basemapLayer('Topographic').addTo(map);

		function onLocationFound(e) {
			var radius = e.accuracy / 2;
      
//Create pop-up to display location accuracy.  Location is coming from IP location or GPS receiver in mobile device
			L.marker(e.latlng).addTo(map)
				.bindPopup("You are within " + radius + " meters from this point").openPopup();

//Create circle to graphically represent location accuracy
			L.circle(e.latlng, radius).addTo(map);
		}

//Code for handling any errors that come up
		function onLocationError(e) {
			alert(e.message);
		}

		map.on('locationfound', onLocationFound);
		map.on('locationerror', onLocationError);

//Locate point and zoom to that location with a zoom level of 16
		map.locate({setView: true, maxZoom: 16});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console