Hi All,
Examples of the Bookmarks widget I have seen so far are based on a Dojo button form widget (dijit.form.DropDownButton) rather than on a select form widget type like dijit.form.ComboBox. Is the Bookmarks widget compatible with a Dojo ComboBox or FilteringSelect widget and if so are there examples around ? I have tried a few things that all point to some sort of incompatibility with Dojo widgets other than the DropDownButton. The reason I'd like a ComboBox is to get auto completion on the bookmarks array.
TIA,
Yves
Yves,
This question is a bit confusing. The Bookmarks dijit is a clickable list. You can display this list using a dropdown button as you mentioned. If you are wanting to filter the list then adding a textbox for filtering would look like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Bookmark Widget (Editable)</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.23/esri/themes/calcite/dijit/calcite.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.23/esri/themes/calcite/esri/esri.css">
<style>
html, body, #map {
height: 100%;
margin: 0;
padding: 0;
}
.bookmark-container {
position: absolute;
top: 100px;
left: 15px;
padding: 1rem;
background: #ffffff;
border-radius: 4px;
border: 1px solid #eeeeee;
}
</style>
<script src="https://js.arcgis.com/3.23/"></script>
<script>
var bookmarks;
require([
"esri/map",
"esri/dijit/Bookmarks",
"dojo/on",
"dijit/registry",
"dojo/parser",
"dijit/form/TextBox",
"dojo/domReady!"
],
function (Map, Bookmarks, on, registry, parser){
parser.parse();
var map = new Map("map", {
basemap: "topo",
center: [-100, 40],
zoom: 4
});
// Create the bookmark widget
// specify "editable" as true to enable editing
bookmarks = new Bookmarks({
map: map,
bookmarks: [],
editable: true
}, "bookmarks");
// Bookmark data objects
var bookmarkJSON = {
first: {
"extent": {
"xmin": -12975151.579395358,
"ymin": 3993919.9969406975,
"xmax": -12964144.647322308,
"ymax": 4019507.292159126,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"name": "Palm Springs, CA"
},
second: {
"extent": {
"xmin": -13052123.666878553,
"ymin": 4024962.9850527253,
"xmax": -13041116.734805504,
"ymax": 4050550.280271154,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"name": "Redlands, California"
},
third: {
"extent": {
"xmin": -13048836.874662295,
"ymin": 3844839.127898948,
"xmax": -13037829.942589246,
"ymax": 3870426.4231173764,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"name": "San Diego, CA"
},
};
// Add bookmarks to the widget
Object.keys(bookmarkJSON).forEach(function (bookmark){
bookmarks.addBookmark(bookmarkJSON[bookmark]);
});
on(registry.byId("filter"), 'change', function(value){
Object.keys(bookmarkJSON).forEach(function (bookmark){
bookmarks.removeBookmark(bookmarkJSON[bookmark].name);
});
var userVal = registry.byId("filter").get('value');
Object.keys(bookmarkJSON).forEach(function (bookmark){
if(bookmarkJSON[bookmark].name.toUpperCase().indexOf(userVal.toUpperCase())> -1){
bookmarks.addBookmark(bookmarkJSON[bookmark]);
}
});
});
});
</script>
</head>
<body class="calcite">
<div id="map"></div>
<div class="bookmark-container">
<input id="filter" data-dojo-type="dijit/form/TextBox"
data-dojo-props="trim:true, intermediateChanges:true, placeholder:'Red'"
style="width:100%;" />
<div id="bookmarks"></div>
</div>
</body>
</html>
Thanx Robert.
Yves,
Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.