Hi all,
I am trying to insert vertically the home button in between the zoom sliders ( + and -). How can I achieve that?
Thank you,
Alex
Alex,
I do this in my maploadhandler function:
initialExtent = map.extent; dojo.create("div", { className: "esriSimpleSliderHomeButton", title: 'Zoom to Full Extent', onclick: function () { if (initialExtent === undefined) { initialExtent = map.extent; } map.setExtent(initialExtent); } }, dojo.query(".esriSimpleSliderIncrementButton")[0], "after"); //get rid of the javascript:void(0) statusbar message. domAttr.remove(dojo.query(".action.zoomTo", map.infoWindow.domNode)[0], 'href'); domAttr.set(dojo.query(".action.zoomTo", map.infoWindow.domNode)[0], 'style', 'cursor:pointer;');
And the css:
.esriSimpleSliderHomeButton { border-bottom: 2px solid #666666; background-image: url(../images/zoomExtent.png); background-repeat: no-repeat; background-position: center; cursor: pointer; } .esriSimpleSliderHomeButton:hover { background-color: rgb(102, 102, 102); background-color: rgba(102, 102, 102, 0.9); }
Thank you, That is super helpful! I was looking for it for a long time now!
Good one Robert, I'd been looking for this one for some time myself-
Thank!
Hi Robert-
Can you tell me where in the api you are pulling the home slider png?
background-image: url(../images/zoomExtent.png);
This is an image that you have stored somewhere. You can also use a data URI
Right, thanks Ken. I thought I could pull it out of my downloaded api somewhere, but this will work too. Thanks for the data URI tip...
Robert,
can you tell me how to change icon of arcgis navigation tools
Veena,
Actually those are text and not icons:
<div id="map_zoom_slider" class="esriSimpleSlider esriSimpleSliderVertical esriSimpleSliderTL" style="z-index: 30;"> <div class="esriSimpleSliderIncrementButton" title="Zoom In"> <span>+</span> </div> <div class="esriSimpleSliderDecrementButton" title="Zoom Out"> <span>–</span> </div> </div>
So you would have to manipulate the dom and replace the span elements with an image. I have never had a desire to do this so I don't have a code sample for that.
Here's some example code:
<!DOCTYPE html> <html> <head> <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></title> <link rel="stylesheet" href="https://js.arcgis.com/3.15/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="https://js.arcgis.com/3.15/esri/css/esri.css"> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #map{ padding:0; } .increment { background-image: url('https://useiconic.com/open-iconic/svg/fullscreen-exit.svg'); background-repeat: no-repeat; background-size: 16px 16px; background-position: center; } .decrement { background-image: url('https://useiconic.com/open-iconic/svg/fullscreen-enter.svg'); background-repeat: no-repeat; background-size: 16px 16px; background-position: center; } </style> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="https://js.arcgis.com/3.15/"></script> <script> var map; require([ "esri/map", "esri/dijit/BasemapGallery", "esri/arcgis/utils", "dojo/parser", "dojo/on", "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dijit/TitlePane", "dojo/domReady!" ], function( Map, BasemapGallery, arcgisUtils, parser, on ) { parser.parse(); map = new Map("map", { basemap: "topo", center: [-105.255, 40.022], zoom: 13 }); //add the basemap gallery, in this case we'll display maps from ArcGIS.com including bing maps var basemapGallery = new BasemapGallery({ showArcGISBasemaps: true, map: map }, "basemapGallery"); basemapGallery.startup(); basemapGallery.on("error", function(msg) { console.log("basemap gallery error: ", msg); }); //remove +- span and replace with SVG map.on("load", function (e) { $('div.esriSimpleSliderIncrementButton').find('span').remove(); $('div.esriSimpleSliderDecrementButton').find('span').remove(); $('div.esriSimpleSliderIncrementButton').append("<div class='increment'></div>"); $('div.esriSimpleSliderDecrementButton').append("<div class='decrement'></div>"); }); }); </script> </head> <body class="claro"> <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:false" style="width:100%;height:100%;margin:0;"> <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" style="padding:0;"> <div style="position:absolute; right:20px; top:10px; z-Index:999;"> <div data-dojo-type="dijit/TitlePane" data-dojo-props="title:'Switch Basemap', closable:false, open:false"> <div data-dojo-type="dijit/layout/ContentPane" style="width:380px; height:280px; overflow:auto;"> <div id="basemapGallery"></div> </div> </div> </div> </div> </div> </body> </html>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.