It looks like the issue is that the title attribute isn't getting removed from the locate button - perhaps due to a timing issue. It seems to work if I wait and remove the text after the locate button has loaded. Here's some sample code that shows this:
var homeText = esriBundle.widgets.homeButton.home.title;
var locateText = esriBundle.widgets.locateButton.locate.title;
geoLocate.on("load", function(){
query('div[title ="' + locateText + '"]').forEach(function(node){
domAttr.remove(node, "title");
domAttr.set(node, "data-title", locateText);
});
});
home.on("load", function(){
//Remove default tooltip for home button
query('div[title ="' + homeText + '"]').forEach(function(node){
domAttr.remove(node, "title");
domAttr.set(node, "data-title", homeText);
});
});
Thanks. How do i use this code then? Here is my full java script: var map;
var bMap = "topo";
function changeBasemap(bm) {
bMap=bm;
map.setBasemap(bMap);
}
require(["esri/map", "esri/toolbars/navigation",
"dojo/on",
"dojo/parser",
"dijit/registry",
"dijit/Toolbar",
"dijit/form/Button",
"esri/dijit/OverviewMap",
"esri/dijit/Scalebar",
"esri/dijit/LocateButton",
"esri/dijit/HomeButton",
"dojo/i18n!esri/nls/jsapi",
"dojo/query",
"dojo/dom-attr",
"dojo/domReady!"],
function(Map, Navigation, on, parser, registry, Toolbar, Button, OverviewMap, Scalebar, LocateButton, HomeButton, esriBundle, query, domAttr ){
esriBundle.widgets.homeButton.home.title = "HOME"
esriBundle.widgets.locateButton.locate.title = "FIND MY LOCATION"
parser.parse();
var navToolbar;
map = new Map("map", {
basemap: "topo",
center: [-107.646372, 43.433484],
zoom: 7,
slider: "small"
});
on(map, "load", addDataLayersInit);
on(map, "layers-add-result", initTOC);
//on(map, "layers-add-result", initTOC_Obs);
var scalebar = new Scalebar({
map: map,
// "dual" displays both miles and kilmometers
// "english" is the default, which displays miles
// use "metric" for kilometers
scalebarUnit: "dual",
attachTo:"bottom-right"
});
geoLocate = new LocateButton({
map: map,
}, "LocateButton");
geoLocate.startup();
query(".zoomLocateButton").forEach(function(node){
//remove the title attribute
//Get the title attribute
if(domAttr.get(node, "title") === esriBundle.widgets.locateButton.locate.title){
//replace the title attribute with data-title
domAttr.remove(node, "title");
domAttr.set(node, "title", esriBundle.widgets.locateButton.locate.title )
}
});
var home = new HomeButton({
map: map
}, "HomeButton");
home.startup();
query(".home").forEach(function(node){
//remove the title attribute
//Get the title attribute
if(domAttr.get(node, "title") === esriBundle.widgets.homeButton.home.title){
//replace the title attribute with data-title
domAttr.remove(node, "title");
domAttr.set(node, "data-title", esriBundle.widgets.homeButton.home.title )
}
});
navToolbar = new Navigation(map);
on(navToolbar, "onExtentHistoryChange", extentHistoryChangeHandler);
registry.byId("zoomprev").on("click", function(){
navToolbar.zoomToPrevExtent();
});
registry.byId("zoomnext").on("click", function(){
navToolbar.zoomToNextExtent();
});
function extentHistoryChangeHandler(){
registry.byId("zoomprev").disabled = navToolbar.isFirstExtent();
registry.byId("zoomnext").disabled = navToolbar.isLastExtent();
}
var overviewMapDijit = new OverviewMap({
map: map,
visible: false,
attachTo: "bottom-right",
width: 200,
height: 200
});
overviewMapDijit.startup();
});