Skip to content

Instantly share code, notes, and snippets.

Avatar
🌍

Raluca Nicola RalucaNicola

🌍
View GitHub Profile
View rotate-around-feature.js
function rotate() {
if (!view.interacting) {
view.goTo({
heading: view.camera.heading + 0.1,
center: view.center
}, {animate: false});
requestAnimationFrame(rotate);
}
}
View rotate-globe.js
function rotate() {
if (!view.interacting) {
const camera = view.camera.clone();
camera.position.longitude -= 0.2;
view.goTo(camera, { animate: false });
requestAnimationFrame(rotate);
}
}
view.when(function () {
View get-camera.js
(function() {
const view = require("esri/views/View").views.getItemAt(0);
const p = view.camera.position;
if (p.spatialReference.isWebMercator || p.spatialReference.isWGS84) {
console.log(`
{
position: [
${p.longitude.toFixed(8)},
${p.latitude.toFixed(8)},
@RalucaNicola
RalucaNicola / set-camera.js
Created Jul 16, 2020
How to set a camera in ArcGIS API for JavaScript
View set-camera.js
const view = new SceneView({
container: "viewDiv",
map: map,
camera: {
heading: 90, // face due east
tilt: 45, // looking from a bird's eye view
position: {
latitude: 38,
longitude: -122,
z: 20000
View spatial-filter-buildings.js
sketchViewModel.on("create", function (event) {
if (event.state === "complete") {
const geometry = event.graphic.geometry;
buildingLayerView.filter = {
geometry: geometry,
spatialRelationship: "contains"
};
}
});
View sketch-polygon.js
const sketchLayer = new GraphicsLayer({
elevationInfo: {
mode: "on-the-ground"
}
});
webscene.add(sketchLayer);
const sketchViewModel = new SketchViewModel({
layer: sketchLayer,
view: view
View time-slider-buildings.js
const start = new Date(1900, 0, 1);
const end = new Date(2020, 0, 1);
const timeSlider = new TimeSlider({
container: "timeContainer",
mode: "cumulative-from-start",
fullTimeExtent: {
start: start,
end: end
},
View webscene-portal-item.js
esriConfig.portalUrl = "http://jsapi.maps.arcgis.com/";
const scene = new WebScene({
portalItem: {
id: "2e38f798f3124f2dae84217839cc43dc"
}
});
@RalucaNicola
RalucaNicola / index.html
Last active Nov 22, 2019
Prototype for elections map
View index.html
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<style>
body {
font-family: Arial, Helvetica, sans-serif;
color: #444;
}
View index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 10px sans-serif;
}
#g1 {
color: #e83a66;
}