Hello, i've got a problem:
when I'am trying add layer to my map, it isn't works:
TypeError: view.graphics is undefined
Without this layer everything ok.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Maps</title>
<style>
html, body, #viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
<script src="https://js.arcgis.com/4.3/"></script>
<script>
require([
"esri/layers/TileLayer",
"esri/Map",
"esri/views/MapView",
"esri/Graphic",
"esri/geometry/Point",
"esri/symbols/SimpleMarkerSymbol",
"esri/geometry/Polyline",
"esri/symbols/SimpleLineSymbol",
"esri/geometry/Polygon",
"esri/symbols/SimpleFillSymbol",
"dojo/domReady!"
], function(Map, MapView,
Graphic, Point, SimpleMarkerSymbol,
Polyline, SimpleLineSymbol,
Polygon, SimpleFillSymbol,
TileLayer
) {
var layer = new TileLayer({
url: "http://www.maps.lt/arcgis/rest/services/mapslt/MapServer"
});
var map = new Map({
basemap: "streets",
layers: [layer]
});
var view = new MapView({
container: "viewDiv",
map: map,
center: [23.27928,55.13558],
zoom: 10
});
var point = new Point({
longitude: 23.29507,
latitude: 55.13501
});
var markerSymbol = new SimpleMarkerSymbol({
color: [226, 119, 40],
outline: {
color: [255, 255, 255],
width: 1
}
});
var attributes = {
Name: "I am a point",
Park: "Griffith Park",
City: "Los Angeles"
};
var popupTemplate = {
title: "{Name}",
content: "I live in <b>{Park}</b> in the city of <b>{City}</b>."
};
var pointGraphic = new Graphic({
geometry: point,
symbol: markerSymbol,
attributes: attributes,
popupTemplate: popupTemplate
});
view.graphics.add(pointGraphic);
var polyline = new Polyline({
paths: [
[23.29026, 55.1816],
[23.26451, 55.09664]
]
});
var lineSymbol = new SimpleLineSymbol({
color: [226, 119, 40],
width: 2
});
var polylineGraphic = new Graphic({
geometry: polyline,
symbol: lineSymbol
});
view.graphics.add(polylineGraphic);
var polygon = new Polygon({
rings: [
[23.27653, 55.15121],
[23.2446, 55.15462],
[23.22915, 55.14439],
[23.23327, 55.12279],
[23.25318, 55.10972],
[23.26486, 55.11625],
[23.27653, 55.15121]
]
});
var fillSymbol = new SimpleFillSymbol({
color: [227, 139, 79, 0.8],
outline: {
color: [255, 255, 255],
width: 1
}
});
var polygonGraphic = new Graphic({
geometry: polygon,
symbol: fillSymbol
});
view.graphics.add(polygonGraphic);
});</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
I only want to add this layer: mapslt (MapServer) and some polygons.
What's wrong? Can anybody help me?