Hello All
I downloaded a ESRI ajavascript template from github... and I want to add a arcgis server web service instead of the webmap id
when I see the index.html file i see the code as : I need to skip the webmap and use my REST web service instead..
var defaults = {
//The ID for the map from ArcGIS.com
webmap: "f5b13dbed07c46cdb783cf361833aa6b", I WANT TO ADD my Service http://111.11.1.1/arcgis/services/test/mapserver
//Modify this to point to your sharing service URL if you are using the portal
sharingurl: "http://www.arcgis.com",//for example: "http://www.arcgis.com",
//The id for the web mapping application item that contains configuration info - in most
////When editing you need to specify a proxyurl (see below) if the service is on a different domain
//Specify a proxy url if you will be editing, using the elevation profile or have secure services or web maps that are not shared with everyone.
proxyurl: "",
//cases this will be null.
appid: "",
//set to true to display the title
displaytitle: true,
//Enter a title, if
Can some one help me out in this
Thanks
Hi Gopi,
Try the following:
var myLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://1.2.3.4/arcgis/rest/services/MyServices/TestService/MapServer", { id: "myTestService", outFields: ["*"], visible: true });
myMap.addLayer(myLayer);
require(["esri/urlUtils"], function (urlUtils) {
var myRule1 = urlUtils.addProxyRule({
proxyUrl: "http://1.2.3.4/myMapProxy/proxy.ashx", // location of the proxy
urlPrefix: "http://4.5.6.7/arcgis/rest/services/" // everything in your map that starts with this will be proxied
});
});
Hope this helps,
Alexei
Alexei many Thanks..
Clarification;
The program is using dojo and
var defaults = {.... } is all built and finally used in the code below..
var app = new utilities.App(defaults, supportsLocalization); |
so the code you typed in above - where will that fit in that defaults variable?
entire index.html that builds using the dojo is below... Can you point out where to add that snippet
dojo.require("utilities.App");
dojo.require("dojo.on");
dojo.require("templateConfig.commonConfig");
var i18n;
dojo.ready(function(){
i18n = dojo.i18n.getLocalization("esriTemplate","template");
var defaults = {
//The ID for the map from ArcGIS.com
webmap: "f5b13dbed07c46cdb783cf361833aa6b",
//Modify this to point to your sharing service URL if you are using the portal
sharingurl: "http://www.arcgis.com",//for example: "http://www.arcgis.com",
//The id for the web mapping application item that contains configuration info - in most
////When editing you need to specify a proxyurl (see below) if the service is on a different domain
//Specify a proxy url if you will be editing, using the elevation profile or have secure services or web maps that are not shared with everyone.
proxyurl: "http://110.74.199.12:7878/arcgis/rest/services/Tax_Map_Publish/MapServer",
//cases this will be null.
appid: "",
//set to true to display the title
displaytitle: true,
//Enter a title, if no title is specified, the webmap's title is used.
title: "",
//Enter a description for the application. This description will appear in the left pane
//if no description is entered the webmap description will be used.
description: "",
//specify an owner for the app - used by the print option. The default value will be the web map's owner
owner: '',
//Specify a color theme for the app. Valid options are gray,blue,purple,green and orange
theme: 'blue',
//Optional tools - set to false to hide the tool
//set to false to hide the zoom slider on the map
displayslider: true,
displaymeasure: true,
displaybasemaps: true,
displayoverviewmap: true,
displayeditor: true,
displaylegend: true,
displaysearch: true,
displaylayerlist: true,
displaybookmarks: true,
displaydetails: true,
displaytimeslider: true,
displayprint: true,
displayprintlegend: false,
displayeditortoolbar: false,
displaymapwidgets:false, //deprecated. After the June 2014 release set displayHome and displayLocate instead
home: true,
locate: true,
//i18n.viewer.main.scaleBarUnits,
//The elevation tool uses the measurement tool to draw the lines. So if this is set
//to true then displaymeasure needs to be true too. NOTE: THis tool is deprecated and should no
//longer be used in the Basic Viewer. Use the new version of the template instead
//https://github.com/Esri/elevation-profile-template
displayelevation: false,
//This option is used when the elevation chart is displayed to control what is displayed when users mouse over or touch the chart. When true, elevation gain/loss will be shown from the first location to the location under the cursor/finger.
showelevationdifference: false,
displayscalebar: true,
displayshare: true,
//Set to true to display the left panel on startup. The left panel can contain the legend, details and editor. Set to true to
//hide left panel on initial startup. 2
leftPanelVisibility: true,
//If the webmap uses Bing Maps data, you will need to provide your Bing Maps Key
bingmapskey: commonConfig.bingMapsKey,
//Get the default map units
units: commonConfig.units,
//specify a group in ArcGIS.com that contains the basemaps to display in the basemap gallery
//example: title:'ArcGIS Online Basemaps' , owner:esri
basemapgroup: {
title: null,
owner: null
},
//Enter the URL's to the geometry service, print task and geocode service.
helperServices: commonConfig.helperServices,
//Set the label in the nls file for your browsers language
printlayouts: [{
layout: 'Letter ANSI A Landscape',
label: i18n.tools.print.layouts.label1,
format: 'PDF'
}, {
layout: 'Letter ANSI A Portrait',
label: i18n.tools.print.layouts.label2,
format: 'PDF'
}, {
layout: 'Letter ANSI A Landscape',
label: i18n.tools.print.layouts.label3,
format: 'PNG32'
}, {
layout: 'Letter ANSI A Portrait',
label: i18n.tools.print.layouts.label4,
format: 'PNG32'
}],
printlayout: false,
printformat: "PNG32",
//Specify the geocoder options. By default uses the geocoder widget with the default locators. If you specify a url value then that locator will be used.
placefinder: {
"url": "",
"countryCode":"",
"currentExtent":false,
"placeholder": "",
"singleLineFieldName":""
},
//when true locations searches use the current map extent.
searchextent: false,
//Set link text and url parameters if you want to display clickable links in the upper right-corner
//of the application.
//ArcGIS.com. Enter link values for the link1 and link2 and text to add links. For example
//url:'http://www.esri.com',text:'Esri'
link1: {
url: '',
text: ''
},
link2: {
url: '',
text: ''
},
//specify the width of the panel that holds the editor, legend, details
leftpanewidth: 228,
//Restrict the map's extent to the initial extent of the web map. When true users
//will not be able to pan/zoom outside the initial extent.
constrainmapextent: false,
//Provide an image and url for a logo that will be displayed as a clickable image
//in the lower right corner of the map. If nothing is specified then the esri logo will appear.
customlogo: {
image: '',
link: ''
},
//embed = true means the margins will be collapsed to just include the map no title or links
embed: false
};
var supportsLocalization = true;
var app = new utilities.App(defaults, supportsLocalization);
dojo.on(app, "ready", function(config){
initMap(config);
});
});
You can use below code to replace webmap id with your custom map service
function add() {
var webmap = {};
webmap.item = {
"title":"custom",
"snippet": "custom",
"extent":[[-70992265.886348, -32560951.057024], [70992265.886348, 32560951.057024]]
};
webmap.itemData = {
"operationalLayers": [{
"url": "http://111.11.1.1/arcgis/services/test/mapserver ",
"visibility": true,
"opacity": 0.75,
"title": "custom",
"itemId": "204d94c9b1374de9a21574c9efa31164"
}],
"baseMap":
{
"baseMapLayers": [{
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer"
},
{
"isReference": true,
"opacity": 1,
"visibility": true,
"url": "http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer"
}],
"title": "World_Terrain_Base"
},
"version": "1.1"
};
return webmap;
}
//Replace your webmapid with the function created above
//The ID for the map from ArcGIS.com
webmap: add(),//"f5b13dbed07c46cdb783cf361833aa6b",
Hello Gopi,
You can also receive a webmap from cartoview in case you want a simple way to return your map. www.cartologic.com/cartoview here is how Cartoview
the steps to create a webmapid with cartoview is listed here