Thanks Rob and Rebeca for always being helpful. I am looking for a widget in WebAppBuilder that performs following functionality on widgt launch (click).
Send to a URL e.g. http://MyServer/MyMapApplication/default.aspx?lon=--80.203&lat=43.035&zoom=15
Is there a widget already available that has built in functionality? Is there a sample widget you could provide.
Solved! Go to Solution.
Raju,
You can modify the URL Button widget for this purpose:
///////////////////////////////////////////////////////////////////////////
// Copyright © 2018 Robert Scheitlin. All Rights Reserved.
///////////////////////////////////////////////////////////////////////////
define([
'dojo/_base/declare',
'dojo/_base/lang',
'jimu/BaseWidget',
'jimu/WidgetManager'
],
function(
declare,
lang,
BaseWidget,
WidgetManager) {
var clazz = declare([BaseWidget], {
name: 'UrlButton',
baseClass: 'widget-urlbutton',
isOpening: false,
onOpen: function(){
if(!this.isOpening){
this.isOpening = true;
//RJS ADD
var mapCeneter = var lat = this.map.extent.getCenter();
var lat = mapCeneter.getLatitude();
var lon = mapCeneter.getLongitude();
var level = this.map.getLevel();
//RJS End Add
//RJS Edit
window.open(this.config.LinkUrl + "?lon=" + lon + "&lat=" + lat + "&zoom=" + level, "_blank");
//RJS End Edit
setTimeout(lang.hitch(this, function(){
this.isOpening = false;
WidgetManager.getInstance().closeWidget(this);
}), 300);
}
}
});
return clazz;
});
Raju,
You can modify the URL Button widget for this purpose:
///////////////////////////////////////////////////////////////////////////
// Copyright © 2018 Robert Scheitlin. All Rights Reserved.
///////////////////////////////////////////////////////////////////////////
define([
'dojo/_base/declare',
'dojo/_base/lang',
'jimu/BaseWidget',
'jimu/WidgetManager'
],
function(
declare,
lang,
BaseWidget,
WidgetManager) {
var clazz = declare([BaseWidget], {
name: 'UrlButton',
baseClass: 'widget-urlbutton',
isOpening: false,
onOpen: function(){
if(!this.isOpening){
this.isOpening = true;
//RJS ADD
var mapCeneter = var lat = this.map.extent.getCenter();
var lat = mapCeneter.getLatitude();
var lon = mapCeneter.getLongitude();
var level = this.map.getLevel();
//RJS End Add
//RJS Edit
window.open(this.config.LinkUrl + "?lon=" + lon + "&lat=" + lat + "&zoom=" + level, "_blank");
//RJS End Edit
setTimeout(lang.hitch(this, function(){
this.isOpening = false;
WidgetManager.getInstance().closeWidget(this);
}), 300);
}
}
});
return clazz;
});
I am looking to get map extent (minX, minY, maxX, maxY). I am getting type error in the widget (. Could you please guide
var minxx = this.map.extent.getMinx(); //TypeError: this.map.extent.xMin is not a function
Raju,
The extent class does not have a getMinx() function. It is just extent.minx.
Thanks Rob. could you please help why i am not getting extent (xmin, xmax, ymin, ymax) in other format (xmin: -8897322.107622242, ymin: 5343300.437750983, xmax: -8885092.18309663, ymax: 5348345.281617797).
{wkid: 102100}.
Is there a way to convert into WGS-84 (minx=-79.82269048690796&miny=43.16071271896362&maxx=-
79.71282720565796&maxy=43.24250936508179).
Your help is appreciated.