Toggle Map

573
4
08-02-2018 10:36 AM
NadirHussain
Occasional Contributor II

if (map.getZoom() > 13) {
visFlag = true;
toggle = new BasemapToggle({
map: map,
visible: true,
basemap: "hybrid",
basemaps:
{
"hybrid": {
"title": "hhh",
"thumbnailUrl": "../Content/images/satellite.png"
},
"topo": {
"title": "fff",
"thumbnailUrl": "../Content/images/topo.png"
}
}
}, "BasemapToggle");

if (toggle) {
console.log("i m inside Visible 13");
toggle.startup();
}

}
else {
if (toggle) {
toggle.destroy();
console.log("destroy")
}
}

}

dear all 

i want to change the toggle map visibility on extent change.but only one time this happened.But one time toggle map appear and disappear.it not comes second time please help.other thing i also want to display  title of  currently selected map 

0 Kudos
4 Replies
NadirHussain
Occasional Contributor II

tried to register widget with id==BasemapToggle but that id is already registered.this error is also i am getting.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nadir,

   Can you add a simple full sample code of this?

0 Kudos
NadirHussain
Occasional Contributor II

Dear robert 

i sovled one issue.

var mapExtentChange = map.on("extent-change", changeHandler);
function changeHandler(evt) {
var extent = evt.extent,
zoomed = evt.levelChange;
var intCount = 0;
if (map.getZoom() > 13) {
if (intCount == 0) {
toggle.startup();
$('#DivBP').css("visibility", "Visible");
intCount++;
}
else if (intCount > 0)
{
$('#DivBP').css("visibility", "Visible");
intCount++;
}

}
else {
var baseMapToggle = dijit.byId('DivBP');
$('#DivBP').css("visibility", "hidden");
}
}

this is my code.the other issue is when i press toggle on baseMapToggle widget.map layer change.But title not change. this title inside red eclipse never change.how to change.Thanks again.

0 Kudos
NadirHussain
Occasional Contributor II

Dear Robert 

 Thanks.I solved all the issues.i override the toggle method of ToggleBaseMap Class.It solved all my issues.

Thanks

Again.

0 Kudos