Created
October 6, 2021 08:43
-
-
Save riccardoklinger/a8f5a6547166e48d5cffc79ee4882492 to your computer and use it in GitHub Desktop.
data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(["jquery"], function(jQuery) { | |
function BasicControl() {}; | |
"use strict"; | |
BasicControl.prototype.initialize = function(oControlHost, fnDoneInitializing, oDataStore) { | |
fnDoneInitializing(); | |
} | |
BasicControl.prototype.draw = function(oControlHost) { | |
console.log('3. Draw') | |
jQuery("head link[rel='stylesheet']").last().after("<link href='https://js.arcgis.com/4.18/esri/css/main.css' rel='stylesheet' />"); | |
require.config({ | |
//baseUrl: 'scripts', | |
paths: { | |
'esri': 'https://js.arcgis.com/4.18/esri' | |
} | |
}); | |
require(["esri/Map","esri/views/MapView", "esri/layers/TileLayer","esri/Graphic", "esri/layers/GraphicsLayer","esri/symbols/TextSymbol", "esri/Color", "esri/symbols/Font", "esri/geometry/Point", "esri/PopupTemplate", "esri/layers/FeatureLayer"], function(Map, MapView, TileLayer, Graphic, GraphicsLayer, TextSymbol, Color, Font, Point, PopupTemplate, FeatureLayer) { | |
var mapContainer = oControlHost.container.id; | |
var map = new Map({ | |
basemap: { | |
baseLayers: [ | |
new TileLayer({ | |
url: "https://webgis.tollcollect.cs.tc.corp/server/rest/services/Betriebsdaten/TC_Basiskarte/MapServer" | |
}) | |
] | |
} | |
}); | |
var tarifabschnitte = new FeatureLayer({ | |
url: | |
"https://webgis.tollcollect.cs.tc.corp/server/rest/services/Betriebsdaten/Betriebsdaten/MapServer/4" | |
}); | |
map.add(tarifabschnitte); | |
var view = new MapView({ | |
container: mapContainer, | |
map: map, | |
center: [12.60,52.05], | |
zoom: 4 | |
}); | |
console.log([geojsonFeature.features[1].geometry.coordinates[1], geojsonFeature.features[1].geometry.coordinates[0]]); | |
//console.log(geojsonFeature); | |
//var graphicsLayer = new GraphicsLayer(); | |
var pt = new PopupTemplate({ // autocasts as new PopupTemplate() | |
title: "Value: {name}", | |
}); | |
console.log(Date.now()) | |
for (var i=0; i < geojsonFeature.features.length;i++){ | |
//var font = new Font("22px", Font.STYLE_NORMAL, Font.VARIANT_NORMAL, Font.WEIGHT_BOLDER); | |
if (geojsonFeature.features[i].geometry.coordinates[1] > 0){ | |
var point = new Point({ | |
longitude: geojsonFeature.features[i].geometry.coordinates[1], | |
latitude: geojsonFeature.features[i].geometry.coordinates[0] | |
}); | |
var markerSymbol = { | |
type: "simple-marker", // autocasts as new SimpleMarkerSymbol() | |
color: [226, 119, 40], | |
size: "10px", | |
outline: { | |
// autocasts as new SimpleLineSymbol() | |
color: [255, 255, 255], | |
width: 0.5 | |
} | |
}; | |
var pointAtt = { | |
name: geojsonFeature.features[i].properties.name, | |
}; | |
var graphic = new Graphic({ | |
geometry: point, | |
symbol: markerSymbol, | |
attributes: pointAtt, | |
popupTemplate: pt | |
}); | |
view.graphics.add(graphic); | |
} | |
} | |
console.log(view.graphics); | |
view.goTo(view.graphics); | |
}) | |
var oPage = oControlHost.page; | |
console.log(Date.now()); | |
} | |
BasicControl.prototype.setData = function(oControlHost, oDataStore) { | |
console.log('2 Set Data') | |
//Default GeoJSON | |
geojsonFeature = { | |
"type": "FeatureCollection", | |
"features": [] | |
} | |
var iRowCount = oDataStore.rowCount; | |
for (var iRow = 0; iRow < iRowCount; iRow++) { | |
var feature = {} | |
feature['type'] = 'Feature' | |
feature['geometry'] = { | |
'type': 'Point', | |
'coordinates': [parseFloat(oDataStore.getCellValue(iRow, 1)), parseFloat(oDataStore.getCellValue(iRow, 2))], | |
} | |
feature['properties'] = { 'name': oDataStore.getCellValue(iRow, 0) } | |
geojsonFeature['features'].push(feature) | |
} | |
}; | |
return BasicControl | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment