Karim,
What does your web console in your web browser say? You need to provide more info in your post if anyone is going to be able to help.
not say any thing every thing is right
Karim,
There is that uncaught type error. Do you use "mid" in your widgets code? Is your widget listed in those that were successfully created?
no i don't use mid and widget successfully created because it appear on screen
Karim,
Well there is not much I can help with unless you share your widgets code.
widget.js
/// <reference path="Widget.html" />
/// <reference path="Widget.html" />
///////////////////////////////////////////////////////////////////////////
// Copyright © 2014 Esri. All Rights Reserved.
//
// Licensed under the Apache License Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///////////////////////////////////////////////////////////////////////////
define([
'dojo/_base/declare',
'jimu/BaseWidget', 'dojo/_base/html',
'dojo/on',
"esri/toolbars/navigation",
'jimu/utils',
'jimu/portalUtils',
"dojo/dom-style", "dijit/Toolbar",
, "dijit/form/Button",'dojo/domReady!'
],
function (
declare,
BaseWidget, html, on,
utils,
PortalUtils,Navigation,
domStyle
) {
var clazz = declare([BaseWidget], {
name: 'NavigationToolbar',
baseClass: 'jimu-widget-navigationtoolbar',
startup: function () {
this.inherited(arguments);
var navToolbar;
/*var element = document.createElement("input");
//Assign different attributes to the element.
element.type = "Button";
element.value = "zoom in";
//element.class = "zoominIcon";
element.name = "kimo"; // And the name too?
element.onclick = function () { // Note this is a function
alert("blabla");
};
html.place(element, this.domNode);*/
navToolbar = new esri.toolbars.Navigation(this.map);
on(navToolbar, "extent-history-change", extentHistoryChangeHandler);
on(document.getElementById("zoomin"), "click", function (e) {
navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);
});
on(document.getElementById("zoomout"), "click", function (e) {
navToolbar.activate(esri.toolbars.Navigation.ZOOM_OUT);
});
on(document.getElementById("zoomfullext"), "click", function (e) {
navToolbar.zoomToFullExtent();
});
on(document.getElementById("zoomprev"), "click", function (e) {
navToolbar.zoomToPrevExtent();
});
on(document.getElementById("zoomnext"), "click", function (e) {
navToolbar.zoomToNextExtent();
});
on(document.getElementById("pan"), "click", function (e) {
navToolbar.activate(esri.toolbars.Navigation.PAN);
});
on(document.getElementById("deactivate"), "click", function (e) {
navToolbar.deactivate();
});
function extentHistoryChangeHandler() {
document.getElementById("zoomprev").disabled = navToolbar.isFirstExtent();
document.getElementById("zoomnext").disabled = navToolbar.isLastExtent();
}
}
});
clazz.inPanel = false;
clazz.hasUIFile = true;
return clazz;
});
widget.html
<div class="nav_gis">
<div id="navToolbar" data-dojo-type="dijit/Toolbar" style="float: left;width:700px">
<button data-dojo-type="dijit/form/Button" id="zoomin" class="zoominIcon">Zoom In</button>
<button data-dojo-type="dijit/form/Button" id="zoomout" class="zoomoutIcon">Zoom Out</button>
<button data-dojo-type="dijit/form/Button" id="zoomfullext" class="zoomfullextIcon">Full Extent</button>
<button data-dojo-type="dijit/form/Button" id="zoomprev" disabled class="zoomprevIcon">Prev Extent</button>
<button data-dojo-type="dijit/form/Button" id="zoomnext" disabled class="zoomnextIcon">Next Extent</button>
<button data-dojo-type="dijit/form/Button" id="pan" class="panIcon">Pan</button>
<button data-dojo-type="dijit/form/Button" id="deactivate" class="deactivateIcon">Deactivate</button>
</div>
</div>
manifest.config
{
"name": "NavigationToolbar",
"platform": "HTML",
"version": "1.2",
"wabVersion": "1.2",
"author": "Esri R&D Center Beijing",
"description": "",
"copyright": "",
"license": "http://www.apache.org/licenses/LICENSE-2.0",
"properties": {
"inPanel": false,
"hasUIFile": true
}
}
Karim,
So in your widget.js you had one of your requires out of order with your vars (very common AMD programming error). You also has an extra comma in your require list and I added some code to your events "this.own" that tell the module to destroy the event handlers when the module is destroyed.
/////////////////////////////////////////////////////////////////////////// // Copyright c 2014 Esri. All Rights Reserved. // // Licensed under the Apache License Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /////////////////////////////////////////////////////////////////////////// define([ 'dojo/_base/declare', 'jimu/BaseWidget', 'dojo/_base/html', 'dojo/on', 'esri/toolbars/navigation', 'jimu/utils', 'jimu/portalUtils', 'dojo/dom-style', 'dijit/Toolbar', 'dijit/form/Button', 'dojo/domReady!' ], function ( declare, BaseWidget, html, on, Navigation, utils, PortalUtils, domStyle ) { var clazz = declare([BaseWidget], { name: 'NavigationToolbar', baseClass: 'jimu-widget-navigationtoolbar', startup: function () { this.inherited(arguments); var navToolbar; /*var element = document.createElement("input"); //Assign different attributes to the element. element.type = "Button"; element.value = "zoom in"; //element.class = "zoominIcon"; element.name = "kimo"; // And the name too? element.onclick = function () { // Note this is a function alert("blabla"); }; html.place(element, this.domNode);*/ navToolbar = new Navigation(this.map); this.own(on(navToolbar, "extent-history-change", extentHistoryChangeHandler)); this.own(on(document.getElementById("zoomin"), "click", function () { navToolbar.activate(Navigation.ZOOM_IN); })); this.own(on(document.getElementById("zoomout"), "click", function () { navToolbar.activate(Navigation.ZOOM_OUT); })); this.own(on(document.getElementById("zoomfullext"), "click", function () { navToolbar.zoomToFullExtent(); })); this.own(on(document.getElementById("zoomprev"), "click", function () { navToolbar.zoomToPrevExtent(); })); this.own(on(document.getElementById("zoomnext"), "click", function () { navToolbar.zoomToNextExtent(); })); this.own(on(document.getElementById("pan"), "click", function () { navToolbar.activate(Navigation.PAN); })); this.own(on(document.getElementById("deactivate"), "click", function () { navToolbar.deactivate(); })); function extentHistoryChangeHandler() { document.getElementById("zoomprev").disabled = navToolbar.isFirstExtent(); document.getElementById("zoomnext").disabled = navToolbar.isLastExtent(); } } }); clazz.inPanel = false; clazz.hasUIFile = true; return clazz; });