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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.


                <!DOCTYPE html>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Customize Map Navigation Animation</title>
    <link rel="stylesheet" href="">
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      body {
        background-color: #FFF;
        overflow: hidden;
        font-family: "Trebuchet MS";
      #sideDiv {
        position: absolute;
        left: 20px;
        top: 20px;
        width: 200px;
        height: 30%;
        margin: 100px 0 0 0;
        z-index: 2000;
        vertical-align: middle;
        text-align: center;
      #bottomDiv {
        position: fixed;
        left: 40%;
        bottom: 20px;
        width: 20%;
        height: 50px;
        margin: 0 ;
        z-index: 2000;
      #LocateButton {
        position: absolute;
        top: 95px;
        left: 20px;
        z-index: 2500;
    <script src=""></script>
      var map;

      require(["esri/map", "esri/dijit/LocateButton","esri/geometry/ScreenPoint","esri/geometry/screenUtils",
               "esri/geometry/Point","esri/geometry/Extent",  "esri/config", "dojo/domReady!"], function(Map,LocateButton,ScreenPoint ,screenUtils, Point, Extent, esriConfig) {
        //configure map animation to be faster = 1; // time in milliseconds, default panDuration: 350 = 1; // default panRate: 25 = 100; // default zoomDuration: 500 = 1; // default zoomRate: 25

        map = new Map("map", {
          basemap: "satellite",
          center: [-93.5, 36.972],
          zoom: 5
        // 48.8584 2.2945  48.80 48.90 2.2 2.4
        // 48.858222 2.294500 
        var extent = new esri.geometry.Extent({
        document.getElementById('sideDiv').innerHTML = "Center: " +extent.getCenter().x + "<br>" +  extent.getCenter().y;
        geoLocate = new LocateButton({
          map: map,           
        }, "LocateButton");       
        // Add on locate functionality
        geoLocate.on("locate", function(e) {          
          var loc = e.position;          
          // Create map point from locate result
          var point = new Point(loc.coords.longitude, loc.coords.latitude);
          //var mapP = map.toScreen(point);         
          // map.centerAt(centeredMapPoint) 
        function centerMap(zoom = null) {
          var currExtent = map.extent;
          // Get dimensions of side div
          var sideDiv = document.getElementById('sideDiv');      
          var centerdMapWidth = map.width - sideDiv.getBoundingClientRect().right;
          // Create centered screen X
          var centeredMapX = centerdMapWidth/2;
          // Get dimensions of bottom div
          var bottomDiv = document.getElementById('bottomDiv');         
          var centerdMapHeight = bottomDiv.getBoundingClientRect().top;
          // Create centered screen Y
          var centeredMapY = map.height - centerdMapHeight/2;
          // Create new center point
          var scrPoint = new ScreenPoint(centeredMapX, centeredMapY);         
          // Create the center point in map units
          var centeredMapPoint = screenUtils.toMapPoint(map.extent, map.width, map.height, scrPoint);
          // Move to the new center
          // Added a timeout to see the difference between the points
          setTimeout(function () {
            document.getElementById('sideDiv').innerHTML += "<br>New center: " + centeredMapPoint.x + "<br>" +  centeredMapPoint.y;
            //Zoom out (for polygons...)
            //map.setZoom(map.getZoom() - 1) 
          }, 2000);      
    <div id='sideDiv'></div>
    <div id='bottomDiv'></div>
    <div id="map">
       <div id="LocateButton"></div>