POST
|
I want to add the custom Tiles ,which is created by Arcgis with catalog. it can get the tile image from server but i can't view in map. my code like this. <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Custom TileLayer - 4.12</title>
<link rel="stylesheet" type="text/css" href="http://localhost/arcgis_js_v412_api/arcgis_js_api/library/4.12/esri/themes/light/main.css"/>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script src="http://localhost/arcgis_js_v412_api/arcgis_js_api/library/4.12/init.js"></script>
<script>
require([
"esri/Map",
"esri/config",
"esri/request",
"esri/Color",
"esri/geometry/Extent",
"esri/geometry/SpatialReference",
"esri/layers/support/TileInfo",
"esri/views/MapView",
"esri/widgets/LayerList",
"esri/layers/BaseTileLayer",
"dojo/domReady!"
], function(
Map, esriConfig, esriRequest, Color,Extent, SpatialReference ,TileInfo,
MapView, LayerList, BaseTileLayer
) {
// *******************************************************
// Custom tile layer class code
// Create a subclass of BaseTileLayer
// *******************************************************
let spatialReference = new SpatialReference({ wkid: 4550 });
let extent=new Extent({
xmin:273521.70494464,
ymin:3302005.502287823,
xmax:440043.09505535045,
ymax:3379261.04,
spatialReference:{wkid:4550}
});
let tileInfo = new TileInfo({
dpi: 96,
rows: 256,
cols: 256,
compressionQuality: 0,
origin: {
x: -5123200,
y: 10002100
},
spatialReference: {
wkid: 4550
},
lods: [
{
level: 0,
levelValue: 0,
resolution:264.5838625010584,
scale: 1000000
},
{
level: 1,
levelValue: 1,
resolution: 132.2919312505292,
scale: 500000
},
{
level: 2,
levelValue: 2,
resolution: 66.1459656252646,
scale: 250000
},
{
level: 3,
levelValue: 3,
resolution: 33.0729828126323,
scale: 125000
},
{
level: 4,
levelValue: 4,
resolution: 16.933367200067735,
scale: 64000
}
]
});
var TintLayer = BaseTileLayer.createSubclass({
properties: {
urlTemplate: null,
tint: {
value: null,
type: Color
} ,
tileInfo: tileInfo,
spatialReference: spatialReference
},
// generate the tile url for a given level, row and column
getTileUrl: function(level, row, col) {
return "http://192.168.20.244/TileCache/Layers/_alllayers/" +
"L" + dojostring.pad(level, 2, '0') + "/" +
"R" + dojostring.pad(row.toString(16), 8, '0') + "/" +
"C" + dojostring.pad(col.toString(16), 8, '0') + "." +
"png";
},
// This method fetches tiles for the specified level and size.
// Override this method to process the data returned from the server.
fetchTile: function(level, row, col) {
// call getTileUrl() method to construct the URL to tiles
// for a given level, row and col provided by the LayerView
var url = this.getTileUrl(level, row, col);
// request for tiles based on the generated url
// set allowImageDataAccess to true to allow
// cross-domain access to create WebGL textures for 3D.
return esriRequest(url, {
responseType: "image",
allowImageDataAccess: true
})
.then(function(response) {
// when esri request resolves successfully
// get the image from the response
var image = response.data;
var width = this.tileInfo.size[0];
var height = this.tileInfo.size[0];
// create a canvas with 2D rendering context
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
canvas.width = width;
canvas.height = height;
// Draw the blended image onto the canvas.
context.drawImage(image, 0, 0, width, height);
return canvas;
}.bind(this));
}
});
// *******************************************************
// Start of JavaScript application
// *******************************************************
// Add stamen url to the list of servers known to support CORS specification.
var stamenTileLayer = new TintLayer({
tint: new Color("#004FBB"),
title: "test"
});
// add the new instance of the custom tile layer the map
var map = new Map({
layers: [stamenTileLayer]
});
// create a new scene view and add the map
var view = new MapView({
container: "viewDiv",
map: map,
center: [360788, 3309983],
extent: extent
});
// create a layer list widget
var layerList = new LayerList({
view: view,
});
view.ui.add(layerList, "top-right");
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
My tile url formate:http://192.168.20.244/TileCache/Layers/_alllayers/L00/R00000061/C0000004f.png what't the problem ,can you help me
... View more
10-31-2019
11:29 PM
|
0
|
1
|
581
|
POST
|
Thank you! it works fine! by the way,how to formate the javascript code in commutiy question like your reply code. I'am newer for the commutiy
... View more
10-16-2019
06:08 PM
|
0
|
1
|
1810
|
POST
|
i want to remove move event when reshape graphic with SketchViewModel ,how to do? view.when(function() {
// Query all buffer features from the school buffers featurelayer
bufferLayer.queryFeatures().then(function(results) {
buffers = results.features[0].geometry;
});
// Add the boundary polygon and new lot polygon graphics
addGraphics();
// Create a new instance of sketchViewModel
sketchViewModel = new SketchViewModel({
view: view,
layer: graphicsLayer,
updateOnGraphicClick: true,
defaultUpdateOptions: {
// set the default options for the update operations
toggleToolOnClick: false // only reshape operation will be enabled
}
});
// Listen to sketchViewModel's update event to do
// graphic reshape or move validation
sketchViewModel.on(["update", "undo", "redo"], onGraphicUpdate);
});
function onGraphicUpdate(event) {
// get the graphic as it is being updated
const graphic = event.graphics[0];
// check if the graphic is intersecting school buffers or is
// still contained by the boundary polygon as the graphic is being updated
intersects = geometryEngine.intersects(buffers, graphic.geometry);
contains = geometryEngine.contains(boundaryPolygon, graphic.geometry);
// change the graphic symbol to valid or invalid symbol
// depending the graphic location
graphic.symbol =
intersects || !contains ? invalidSymbol : validSymbol;
// check if the update event's the toolEventInfo.type is move-stop or reshape-stop
// then it means user finished moving or reshaping the graphic, call complete method.
// this will change update event state to complete and we will check the validity of the graphic location.
if (
event.toolEventInfo &&
event.toolEventInfo.type === "reshape-stop"
) {
if (contains && !intersects) {
//sketchViewModel.complete();
}
} else if (event.state === "cancel" || event.state === "complete") {
// graphic moving or reshaping has been completed or cancelled
// if the graphic is in an illegal spot, call sketchviewmodel's update method again
// giving user a chance to correct the location of the graphic
if (!contains || intersects) {
sketchViewModel.update([graphic], { tool: "reshape" });
}
} else if (
event.toolEventInfo &&
event.toolEventInfo.type === "move-start"
) {
// How to stop move here?
return;
} else if (
event.toolEventInfo &&
event.toolEventInfo.type === "move"
) {
return;
} else if (
event.toolEventInfo &&
event.toolEventInfo.type === "move-stop"
) {
return;
}
}
... View more
10-15-2019
07:31 PM
|
0
|
5
|
2157
|
POST
|
how to hide the layer name in legend? like the "Rivers" in the example Map with legend , Or can i change the text ?
... View more
09-20-2016
12:53 AM
|
0
|
1
|
2259
|
POST
|
thank you for your reply, I find "support Dynamic Layers:false",When you go to your REST service directory for that map service.how to fix the service to support Dynamic Layers?
... View more
09-19-2016
05:57 PM
|
0
|
3
|
506
|
POST
|
I find there is no wrong wtith map service,how to fix ? when I comment the code "DyLayer.setLayerDrawingOptions(optionArray);", the dynamic layer show ,so it mean my service is ok。 is there anythong wrong? should I config the proxy ?
... View more
09-18-2016
09:40 PM
|
0
|
5
|
506
|
POST
|
I try to ClassbreaksRenderer with dynamiclayer, But I get the problem "dynamiclayers is not enabled on this MapService", My Code is # map = new esri.Map("map", { extent: extentNingbo32651, center: [605326.8575680437, 106118.09019766698]}); var zwmap = new esri.layers.ArcGISTiledMapServiceLayer("http://"+location.hostname+":6080/arcgis/rest/services/xxxx/MapServer", { id: "zw", opacity: 1 }); map.addLayer(zwmap); var DyLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://192.168.1.1:6080/arcgis/rest/services/xxxx/MapServer", { id: "zhen", opacity: 0.8 }); DyLayer.setVisibleLayers([0]); var layerDefs = []; layerDefs[0] = "FNAME='AA'"; DyLayer.setLayerDefinitions(layerDefs); var Dyrenderer = new esri.renderer.ClassBreaksRenderer(null, "OBJECTID"); var Dyoutline = new esri.symbol.SimpleLineSymbol("solid", new esri.Color([205, 192, 197]), 1); var Dycolors = [ new esri.Color([255, 51, 51, 0.8]), new esri.Color([255, 51, 51, 0.8]), new esri.Color([255, 51, 51, 0.8]), new esri.Color([255, 51, 51, 0.8]), new esri.Color([255, 51, 51, 0.8]) ]; Dyrenderer.addBreak(0, 1, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[0])); Dyrenderer.addBreak(1, 3, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[1])); Dyrenderer.addBreak(3, 5, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[2])); Dyrenderer.addBreak(5, 20, esri.symbol.SimpleFillSymbol("solid", Dyoutline, Dycolors[3])); Dyrenderer.addBreak(20, 200, esri.symbol.SimpleFillSymbol("solid",Dyoutline,Dycolors[4])); var drawingOptions = new esri.layers.LayerDrawingOptions(); drawingOptions.renderer = Dyrenderer; var optionArray = []; optionArray[0] = drawingOptions; var drawingOptions = new esri.layers.LayerDrawingOptions(); drawingOptions.renderer = Dyrenderer; var optionArray = []; optionArray[0] = drawingOptions; DyLayer.setLayerDrawingOptions(optionArray); map.addLayer(DyLayer); # I debug with firefox,when run the "DyLayer.setLayerDrawingOptions(optionArray);",I get the error"dynamicLayers is not enabled on this MapService"
... View more
09-18-2016
12:20 AM
|
0
|
7
|
1691
|
POST
|
I modify the example online Print | ArcGIS API for JavaScript 3.17 , I create tht 136 polygons of city boundary with local json data on map , it still print error!I put the code into github GitHub - yanliasdf789/Test1: arcgis for js print error with larte features
... View more
09-01-2016
06:28 PM
|
0
|
0
|
599
|
POST
|
1. I find with ff the print request default is "post" method ,so I need't to change the request? 2. when i fire the request directly at the REST endpoint? get the error
... View more
08-31-2016
02:44 AM
|
0
|
3
|
599
|
POST
|
I get the error when create more than 100 polygon ""Error executing tool.: ERROR 000735: Web Map as JSON: Value is required The value is empty. The value is empty. ERROR 000735: Web Map as JSON: Value is required" the value is missing the size of "Web Map as JSON" is limited?
... View more
08-30-2016
12:52 AM
|
0
|
5
|
599
|
POST
|
yes, my steps like this "query a set of polygons --> add the result as graphics on map and then --> print", because the query polygon don't have the attibute fields value,i store the attibute value in other sql server database. so i can't query to the Definition Expression and then try to print According to the attibute fields value.
... View more
08-29-2016
05:44 PM
|
0
|
1
|
599
|
POST
|
I create 100 polygon features in map,then i print the map with the features,But I run the printTask , the server is collapse; I create 20 polygon the print the result is ok. the number for printTask is limit? I use the arcgis api for js 3.17! function ShowByZhen(id) {
var queryTask = new esri.tasks.QueryTask("http://192.168.20.1:6080/arcgis/rest/services/zhen/MapServer/0");
var query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.where = "1=1";
queryTask.execute(query, ShowByZhen_ShowResults);
queryTask.on("error", queryTaskErrorHandler); } function ShowByZhen_ShowResults(results) { // var symbol = new esri.symbol.SimpleFillSymbol().setColor(new esri.Color([205, 192, 197,0.5])).outline.setColor(new esri.Color([189, 0, 38, 0.5]));
var symbol = new esri.symbol.SimpleFillSymbol().setColor(new esri.Color([205, 193, 197, 0.5]));
var fss = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new esri.Color([205, 192, 197]), 2),
new esri.Color([255,255,0,0.25]));
alert(results.features.length);
var resultCount = results.features.length;
for(var i=0;i<resultCount;i++)
{
var mFeature = results.features;
var mFeatureAttribute = results.features.attributes;
mFeatureAttribute["moneyfinish"] = 10000*i;
if (i < 130) {
mFeature.symbol = fss;
map.graphics.add(mFeature);
}
}
}
function Print() {
var printUrl="http://192.168.20.1:6080/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
printTask = new esri.tasks.PrintTask(printUrl, { async: true });
params = new esri.tasks.PrintParameters();
params.map = map;
//*****print
var ptemplate = new esri.tasks.PrintTemplate();
ptemplate.layout = "A3 Landscape";
// ptemplate.layout = "MAP_ONLY";
ptemplate.format = "jpg";
ptemplate.layoutOptions = {
legendlayers: [],
scalebarUnit: "Meters",
titleText: Titletxt
}
// use the extent of the webmap in the output PDF
ptemplate.preserveScale = false;
params.template = ptemplate;
// params.template = "A3 Landscape";
printTask.execute(params, printComplete);
}
... View more
08-29-2016
02:09 AM
|
0
|
10
|
1531
|
Title | Kudos | Posted |
---|---|---|
1 | 09-02-2016 09:13 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|