Select to view content in your preferred language

Styling Attribute Inspector in Bootstrap

3268
4
01-04-2016 05:35 AM
KeithGerhartz1
Frequent Contributor

I am attempting to include the AttributeInspector widget in a Bootstrap app but can't seem to get it to style as expected. Date picker does not appear in a popup, drop downs do not work and the associated fields display as three stacked text boxes, etc.

I know I should not use Claro in combination. Tyring it causes the display to change and improve a bit but still not good and not what should be done in any case.

Any guidance for a Bootstrap newbie?

<Head> listed below. Thanks.

Keith

<head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

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

    <!--    <meta name="description" content="">

    <meta name="author" content="">

    <!-- Safari iOS - apps only -->

    <meta name="apple-mobile-web-app-capable" content="yes">

    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- Chrome for Android - NEW! -->

    <meta name="mobile-web-app-capable" content="yes">

    <link rel="apple-touch-icon" href="images/brand.png">

    <link rel="shortcut icon" href="images/favicon.ico">

    <title>Bootstrap Map JS - Get Started</title>

    <!-- Bootstrap core CSS -->

    <link href="https://community.esri.com//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">    

    <!-- Custom styles for this template -->

    <!-- <link href="css/style.css" rel="stylesheet">-->

    <!-- Bootstrap-map-js -->

    <link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css">

    <link rel="stylesheet" href="https://community.esri.com//esri.github.io/bootstrap-map-js/src/css/bootstrapmap.css">

    <!--<link rel="stylesheet" href="https://js.arcgis.com/3.15/dijit/themes/claro/claro.css">-->

    <style type="text/css">

      #mapDiv {

        min-height: 100%;

        max-height: 100%;

      }

      #search {

         display: block;

      }

    </style>

  </head>

0 Kudos
4 Replies
ChrisSmith7
Honored Contributor

Do you have the rest of your code that will highlight your issue? Right off the bat, I do see the href links aren't complete... The browser might resolve them, though.

0 Kudos
KeithGerhartz1
Frequent Contributor

Here is the code. Thanks for the quick reply.

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

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

    <!--    <meta name="description" content="">

    <meta name="author" content="">

    <!-- Safari iOS - apps only -->

    <meta name="apple-mobile-web-app-capable" content="yes">

    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- Chrome for Android - NEW! -->

    <meta name="mobile-web-app-capable" content="yes">

    <link rel="apple-touch-icon" href="images/brand.png">

    <link rel="shortcut icon" href="images/favicon.ico">

    <title>Bootstrap Map JS - Get Started</title>

    <!-- Bootstrap core CSS -->

    <link href="https://community.esri.com//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

       

    <!-- Custom styles for this template -->

    <!-- <link href="css/style.css" rel="stylesheet">-->

    <!-- Bootstrap-map-js -->

    <link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css">

    <link rel="stylesheet" href="https://community.esri.com//esri.github.io/bootstrap-map-js/src/css/bootstrapmap.css">

    <!--<link rel="stylesheet" href="https://js.arcgis.com/3.15/dijit/themes/claro/claro.css">-->

    <style type="text/css">

      #mapDiv {

        min-height: 100%;

        max-height: 100%;

      }

      #search {

         display: block;

      }

    </style>

  </head>

  <body>

      <div class="panel panel-primary panel-fixed">

          <div class="panel-body">

              <div id="editorDiv"></div>

              <div id="attributeDiv"></div>

          </div>

      </div>

      <div id="mapDiv">

          <img src='images/crosshairs-gray.png' id="findMe" class='find_me' />

      </div>

      <div class="navbar navbar-inverse navbar-fixed-top">

          <div class="container">

              <div class="navbar-header">

                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

                      <span class="icon-bar"></span>

                      <span class="icon-bar"></span>

                      <span class="icon-bar"></span>

                  </button>

              </div>

              <div class="collapse navbar-collapse">

                  <ul class="nav navbar-nav">

                      <li class="active dropdown" id="basemapList">

                          <a href="" class="dropdown-toggle" data-toggle="dropdown">Maps <b class="caret"></b></a>

                          <ul class="dropdown-menu" id="myDropdown">

                              <li><a href="#">Manage Layers</a></li>

                              <li><a href="#">Use Color Basemap</a></li>

                              <li><a href="#">Use Greyscale Basemap</a></li>

                              <li><a href="#">Use Aerial Basemap</a></li>

                          </ul>

                      </li>

                      <li><a id="geosearchNav" href="#">Search</a></li>

                      <li><a id="aboutNav">About</a></li>

                  </ul>

              </div>

          </div>

      </div>

      <div class="modal fade" id="geosearchModal" style="display: none;" aria-hidden="true">

          <div class="modal-dialog">

              <div class="modal-content">

                  <div class="modal-header">

                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>

                      <h4 class="modal-title">Search</h4>

                  </div>

                  <div class="modal-body">

                      <div class="form-group">

                          <div id="search"></div>

                      </div>

                      <form id="geosearch-form" class="form-inline">

                          <button id="btnDismiss" type="submit" class="btn btn-default btn-fixed" data-dismiss="modal">Dismiss</button>

                      </form>

                  </div>

              </div>

              <!-- /.modal-content -->

          </div>

          <!-- /.modal-dialog -->

      </div>

      <div class="modal fade" id="aboutModal" style="display: none;" aria-hidden="true">

          <div class="modal-dialog">

              <div class="modal-content">

                  <div class="modal-header">

                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>

                      <h4 class="modal-title">About</h4>

                  </div>

                  <div class="modal-body">

                      <div class="form-group">

                          <div id="aboutContent"></div>

                      </div>

                      <form id="Form1" class="form-inline">

                          <button id="Button2" type="submit" class="btn btn-default btn-fixed" data-dismiss="modal">Dismiss</button>

                      </form>

                  </div>

              </div>

              <!-- /.modal-content -->

          </div>

          <!-- /.modal-dialog -->

      </div>

      <div class="modal fade" id="layersModal" style="display: none;" aria-hidden="true">

          <div class="modal-dialog">

              <div class="modal-content">

                  <div class="modal-header">

                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>

                      <h4 class="modal-title">Layers</h4>

                  </div>

                  <div class="modal-body">

                      <div class="form-group">

                          <div id="layersContent">vsvvsv</div>

                      </div>

                      <form id="Form2" class="form-inline">

                          <button id="Button1" type="submit" class="btn btn-default btn-fixed" data-dismiss="modal">Dismiss</button>

                      </form>

                  </div>

              </div>

              <!-- /.modal-content -->

          </div>

          <!-- /.modal-dialog -->

      </div>

  </body>

    <script type="text/javascript">

        var package_path = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));

        var dojoConfig = {

            //The location.pathname.replace() logic below may look confusing but all its doing is

            // enabling us to load the api from a CDN and load local modules from the correct location.

            packages: [{

                name: "application",

                location: package_path + '/src/js'

            }, {

                name: "bootstrap",

                location: "//rawgit.com/xsokev/Dojo-Bootstrap/master"

            }]

        };

    </script>

    <script src="//js.arcgis.com/3.15"></script>

    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

    <script>

        require([

            "esri/domUtils",

            "dijit/registry",

            "esri/dijit/Popup",

            "esri/InfoTemplate",

            "esri/tasks/IdentifyTask",

            "esri/tasks/IdentifyParameters",

            "esri/dijit/Search",

            "esri/dijit/editing/Editor",

            "esri/dijit/AttributeInspector",

            "esri/dijit/editing/TemplatePicker",

            "esri/layers/GraphicsLayer",

            "esri/tasks/GeometryService",

            "esri/SpatialReference",

            "esri/geometry/Point",

            "esri/map",

            "esri/dijit/BasemapGallery",

            "esri/dijit/BasemapLayer",

            "esri/dijit/Basemap",

            "esri/layers/FeatureLayer",

            "esri/layers/ArcGISTiledMapServiceLayer",

            "esri/dijit/Scalebar",

            "esri/graphic",

            "esri/Color",

            "esri/symbols/SimpleFillSymbol",

            "esri/symbols/SimpleLineSymbol",

            "esri/symbols/SimpleMarkerSymbol",

            "esri/symbols/PictureMarkerSymbol",

            "application/bootstrapmap",

            "dojo/parser",

            "dojo/query",

            "dojo/touch",

            "dojo/dom",

            "dojo/on",

            "dojo/_base/array",

            "dojo/_base/connect",

            "dojo/dom-construct",

            "bootstrap/Modal",

            "bootstrap/Collapse",

            "bootstrap/Dropdown",

            "dojo/domReady!"],

          function (

            domUtils,

            registry,

            Popup,

            InfoTemplate,

            IdentifyTask,

            IdentifyParameters,

            Search,

            Editor,

            AttributeInspector,

            TemplatePicker,

            GraphicsLayer,

            GeometryService,

            SpatialReference,

            Point,

            Map,

            BasemapGallery,

            BasemapLayer,

            Basemap,

            FeatureLayer,

            ArcGISTiledMapServiceLayer,

            Scalebar,

            Graphic,

            Color,

            SimpleFillSymbol,

            SimpleLineSymbol,

            SimpleMarkerSymbol,

            PictureMarkerSymbol,

            BootstrapMap,

            parser,

            query,

            touch,

            dom,

            on,

            arrayUtils,

            connect,

            domConstruct)

          {

              parser.parse();

              var graphic;

              var identifyTask;

              var identifyParams;

              var gsvc = new GeometryService("http://wpk-gis01/arcgis/rest/services/Utilities/Geometry/GeometryServer");

              basemapColor = new ArcGISTiledMapServiceLayer("http://wpk-gis01/arcgis/rest/services/BaseMapColor/MapServer");

              basemapGreyscale = new ArcGISTiledMapServiceLayer("http://wpk-gis01/arcgis/rest/services/BaseMapGreyscale/MapServer");

              basemapAerial = new ArcGISTiledMapServiceLayer("http://wpk-gis01/arcgis/rest/services/Aerials/MapServer");

              var myLocationLayer = new GraphicsLayer({ id: "location" });

              var map = BootstrapMap.create("mapDiv", {

                  zoom: 0

              });

              var currentBasemap = []

              currentBasemap.push(basemapColor);

              map.addLayer(basemapColor);

              map.reorderLayer(basemapColor, 0);

              var scalebar = new Scalebar({

                  map: map,

                  scalebarUnit: "dual"

              });

              //query("#layersContent").replaceWith("test");

              //query("#layersModal").modal("show");

              map.addLayer(myLocationLayer);

              map.on("layers-add-result", initEditor);

              var incidentLayer = new FeatureLayer("http://wpk-gis01/arcgis/rest/services/InfoShare_DataEditing/FeatureServer/0", {

                  mode: FeatureLayer.MODE_ONDEMAND,

                  outFields: ["*"], id: "incidentLayer"

              });

              //incidentLayer.setSelectionSymbol(new SimpleMarkerSymbol().setColor(new Color("red")));

              map.addLayers([incidentLayer]);

              var incidentCommentsLayer = new FeatureLayer("http://wpk-gis01/arcgis/rest/services/InfoShare_DataEditing/FeatureServer/1", {

                  outFields: ["*"], id: "incidentCommentsLayer"

              });

              function initEditor(evt)

              {

                  var layers = arrayUtils.map(evt.layers, function (result)

                  {

                      return { featureLayer: result.layer };

                  });

                  var attributeInspector = new AttributeInspector({ layerInfos: layers }, "attributeDiv");

                  var settings = {

                      attributeInspector: attributeInspector,

                      map: map,

                      layerInfos: layers,

                      toolbarVisible: false

                  };

                  var params = { settings: settings };

                  var myEditor = new Editor(params, 'editorDiv');

                  myEditor.startup();

              }

              //map.on("load", mapReady);

              //var parcelsURL = "http://wpk-gis01/arcgis/rest/services/BaseMapGreyscale/MapServer";

              //function mapReady()

              //{

              //    map.on("click", executeIdentifyTask);

              //    identifyTask = new IdentifyTask(parcelsURL);

              //    identifyParams = new IdentifyParameters();

              //    identifyParams.tolerance = 3;

              //    identifyParams.returnGeometry = true;

              //    identifyParams.layerIds = [3, 20];

              //    identifyParams.layerOption = IdentifyParameters.LAYER_OPTION_VISIBLE;

              //    identifyParams.width = map.width;

              //    identifyParams.height = map.height;

              //};

              //function executeIdentifyTask(event)

              //{

              //    identifyParams.geometry = event.mapPoint;

              //    identifyParams.mapExtent = map.extent;

              //    var deferred = identifyTask

              //      .execute(identifyParams)

              //      .addCallback(function (response)

              //      {

              //          return arrayUtils.map(response, function (result)

              //          {

              //              var feature = result.feature;

              //              var layerName = result.layerName;

              //              feature.attributes.layerName = layerName;

              //              if (layerName === 'Parcels - Orange')

              //              {

              //                  var infoTemplateParcel = new InfoTemplate("Parcel",

              //                    "${PARCEL}");

              //                  feature.setInfoTemplate(infoTemplateParcel);

              //              }

              //              else if (layerName === 'Cities - Orange')

              //              {

              //                  var infoTemplateCities = new InfoTemplate("Cities",

              //                    "${CITY_NAME}");

              //                  feature.setInfoTemplate(infoTemplateCities);

              //              }

                           

              //              return feature;

              //          });

              //      });

              //    map.infoWindow.setFeatures([deferred]);

              //    map.infoWindow.show(event.mapPoint);

              //}

              function changeLayer(layerName)

              {

                  map.removeLayer(currentBasemap[0])

                  currentBasemap.length = 0;

                  currentBasemap.push(layerName)

                  map.addLayer(layerName)

                  map.reorderLayer(layerName, 0);

              }

              function findMe()

              {

                  var options = {

                      enableHighAccuracy: true,

                      timeout: 5000,

                      maximumAge: 0

                  };

                  if (navigator.geolocation)

                  {

                      navigator.geolocation.getCurrentPosition(

                      function (position)

                      {

                          var pointin = new Point(position.coords.longitude, position.coords.latitude, new SpatialReference({

                              wkid: 4326

                          }));

                          gsvc.project([pointin], new SpatialReference({ wkid: 2236 }), function (projectedPoints)

                          {

                              var pt = projectedPoints[0];

                              var graphic = new Graphic(pt, new PictureMarkerSymbol('images/i_target.png', 38, 38));

                              myLocationLayer.add(graphic);

                              map.centerAndZoom(pt, 5);

                          });

                          var interval = setInterval(function ()

                          {

                              clearInterval(interval);

                              map.getLayer('location').clear();

                          }, 5000);

                      }, function (err)

                      {

                          console.warn('ERROR(' + err.code + '): ' + err.message);

                      }, options);

                  }

                  else

                  {

                      alert("Browser doesn't support Geolocation. Visit http://caniuse.com to see browser support for the Geolocation API.");

                  }

              }

              //UI EVENTS

              var s = new Search({

                  map: map,

                  enableHighlight: false

              }, "search");

              s.startup();

              on(s, 'select-result', function (e)

              {

                  query("#geosearchModal").modal("hide");

              });

              query("#basemapList li").on(touch.press, function (e)

              {

                  e.preventDefault();

                  switch (e.target.text)

                  {

                      case "Use Color Basemap":

                          changeLayer(basemapColor);

                          break;

                      case "Use Greyscale Basemap":

                          changeLayer(basemapGreyscale);

                          break;

                      case "Use Aerial Basemap":

                          changeLayer(basemapAerial);

                          break;

                      case "Manage Layers":

                          query("#layersModal").modal("show");

                          collapseNavbarAfterSelection(e);

                          break;

                  }

                  collapseNavbarAfterSelection(e);

              });

              query("#findMe").on(touch.press, function (e)

              {

                  e.preventDefault();

                  findMe();

              });

              query("#geosearchNav").on('click', function (e)

              {

                  query("#geosearchModal").modal("show");

                  collapseNavbarAfterSelection(e);

              });

              query("#aboutNav").on('click', function (e)

              {

                  query("#aboutModal").modal("show");

                  collapseNavbarAfterSelection(e);

              });

              function collapseNavbarAfterSelection(e)

              {

                  if (query(".navbar-collapse.in").length > 0)

                  {

                      e.stopPropagation();

                      query(".navbar-toggle")[0].click();

                  } else

                  {

                      e.stopPropagation();

                  }

              }

          });

    </script>

</html>

0 Kudos
ChrisSmith7
Honored Contributor

Are you sure your bootstrap module is sourced correctly? It seems to be throwing a 404 for me.

0 Kudos
KeithGerhartz1
Frequent Contributor

Not getting an error here.

0 Kudos