HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>Remarquables</title>
<link rel="icon" type="image/x-icon" href="style/favicon.png"> <!--icone de la page web, s'affiche à droite de l'onglet. Disponible ici : https://github.com/JapaLenos/JS-API/blob/main/Jardins-Parisiens/style/favicon.png-->
<link
rel="stylesheet"
href="style/style.css"
/> <!--lien vers ma feuille de style personnalisée. Attention à adapter le chemin à votre projet-->
<link
rel="stylesheet"
href="https://js.arcgis.com/4.27/esri/themes/light/main.css"
/><!--lien vers la feuille de style de l'API.-->
<script src="https://js.arcgis.com/4.27/"></script><!--lien vers l'API JavaScript d'ArcGIS, nous permettant de faire appel à ses services-->
<script src="app/step5-labels-main.js"></script><!--lien vers mon code JavaScript. Attention à adapter le chemin à votre projet-->
</head>
<body>
<div id="full">
<div id="viewDiv"></div><!--balise div qui contiendra la vue de la carte-->
<div class="mentions"><!--optionnel : habillage du site = ajout des crédits-->
<h4>
RÉALISÉ AVEC
<a
href="https://developers.arcgis.com/javascript/latest/"
target="_blank"
>L'API JAVASCRIPT D'ARCGIS</a
>
<br/>GITHUB :
<a
href="https://github.com/JapaLenos/JS-API/tree/main/Jardins-Parisiens"
target="_blank"
>@JAPALENOS</a
><br/>
DONNÉES ISSUES DU
<a
href="https://opendata.paris.fr/explore/dataset/arbresremarquablesparis/export/"
target="_blank"
>PORTAIL OPEN DATA PARIS | DATA
</a>
</h4>
</div>
</div>
</body>
</html>
body{
user-select: none;
margin: 0 ;
}
,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
position : relative
}
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
position : absolute
}
h1 {
padding-top : 1.5%;
font-weight: bolder;
font-size: 450%;
font-family: "Playfair Display", "Avenir Next", "Avenir", "Helvetica Neue", sans-serif;
color: #7B656F;
text-shadow: 1px 1px 2px white;
opacity : 90%;
position: absolute;
text-align: center;
height : 10%;
margin: auto;
z-index: 1;
}
h2 {
font-family: "Playfair Display", "Avenir Next", "Avenir", "Helvetica Neue", sans-serif;
}
h2.esri-widget__heading {
color: #7B656F;
}
h3 {
padding-top : 1%;
font-weight: normal;
font-size: 70%;
font-family: "Avenir Next", "Avenir", "Helvetica Neue", sans-serif;
color: rgb(104, 104, 104);
position: absolute;
z-index: 9;
text-align: center;
width : 100%;
height : 10%;
text-align: center;
margin: auto;
}
h4 {
padding-top : 1%;
font-weight: bold;
font-size: 70%;
font-family: "Avenir Next", "Avenir", "Helvetica Neue", sans-serif;
color: #473B40;
position: absolute;
z-index: 10;
text-align: left;
margin-left: 5%;
bottom : 1%;
}
a {
color: #7B656F;
font-weight: bold;
text-decoration: none;
text-shadow: -1px 0 #FFF, 0 1px #FFF, 1px 0 #FFF, 0 -1px #FFF
}
div.esri-widget--button {
background-color: #FFF;
color: #7B656F;
z-index: 10
}
.label-wrapper {
display: flex;
cursor: pointer;
}
require([
"esri/Map",
"esri/Basemap",
"esri/views/SceneView",
"esri/layers/GeoJSONLayer",
"esri/popup/content/TextContent",
"esri/popup/content/MediaContent",
"esri/popup/content/ImageMediaInfo",
"esri/popup/content/support/ImageMediaInfoValue"
],
(Map, Basemap, SceneView ,GeoJSONLayer,TextContent,MediaContent,ImageMediaInfo,ImageMediaInfoValue) => {
const map = new Map({
basemap: new Basemap({
portalItem: {
id: "0560e29930dc4d5ebeb58c635c0909c9" // References the 3D Topographic Basemap
}
})
});
const view = new SceneView({
container: "viewDiv",
map: map,
camera: {
position: {
longitude: 2.340861136194503,
latitude: 48.88276594605576,
z: 178.8139155479148,
},
heading: 29.620133897254565,
tilt: 65.59724234196116,
},
popup: { //épinglera automatiquement les fenêtres contextuelles en bas à droite
dockEnabled: true,
dockOptions: {
position: "bottom-right",
breakpoint: false,
buttonEnabled: false
},
}
});
view.when(() => {
///////Modification de la symbologie
// convenience function to retrieve the WebStyleSymbols based on their name
function getTreeSymbol(name) {
return {
type: "web-style", // autocasts as new WebStyleSymbol()
name: name,
styleName: "EsriLowPolyVegetationStyle"
};
}
const treeRenderer = {
type: "unique-value", // autocasts as new UniqueValueRenderer()
field: "arbres_libellefrancais",
defaultSymbol: getTreeSymbol("Chilopsis"),
uniqueValueInfos: [
{
value: "Aulne",
symbol: getTreeSymbol("Frangula")
},
{
value: "Bouleau",
symbol: getTreeSymbol("Betula")
},
{
value: "Cèdre",
symbol: getTreeSymbol("Calocedrus")
},
{
value: "Chêne",
symbol: getTreeSymbol("Quercus Rubra")
},
{
value: "Cyprès Chauve",
symbol: getTreeSymbol("Taxodium")
},
{
value: "Erable",
symbol: getTreeSymbol("Acer")
},
{
value: "Hêtre",
symbol: getTreeSymbol("Fagus")
},
{
value: "Magnolia",
symbol: getTreeSymbol("Magnolia")
},
{
value: "Marronnier",
symbol: getTreeSymbol("Castanea")
},
{
value: "Noisetier de Byzance",
symbol: getTreeSymbol("Hamamelis")
},
{
value: "Noyer",
symbol: getTreeSymbol("Juglans")
},
{
value: "Oranger des Osages",
symbol: getTreeSymbol("Citrus")
},
{
value: "Orme",
symbol: getTreeSymbol("Ulmus")
},
{
value: "Orme de Sibérie",
symbol: getTreeSymbol("Ulmus")
},
{
value: "Platane",
symbol: getTreeSymbol("Platanus")
},
{
value: "Pin",
symbol: getTreeSymbol("Pinus")
},
{
value: "Saule",
symbol: getTreeSymbol("Salix")
},
{
value: "Sequoia",
symbol: getTreeSymbol("Sequoiadendron")
},
{
value: "Tilleul",
symbol: getTreeSymbol("Tilia")
},
],
visualVariables: [
{
type: "size",
field: "arbres_hauteurenm",
axis: "height",
valueUnit : "meters"
}
]
};
/////Création d'une couche à partir du JSON
const arbresRemarquables = new GeoJSONLayer({
url: "https://raw.githubusercontent.com/JapaLenos/JS-API/main/Jardins-Parisiens/app/arbresremarquablesparis.geojson",
copyright: "Arbres remarquables - Open portail Paris Data",
renderer: treeRenderer,
elevationInfo: {
mode: "on-the-ground"
}
});
//Ajout d'une couche à la carte
map.add(arbresRemarquables);
/////Création des popups
const textElement1 = new TextContent();
textElement1.text = "Cet arbre remarquable est un <b>{com_nom_usuel}</b> (nom vernaculaire) ou <b>{com_nom_latin}</b> (nom latin). Il appartient à l'espèce <b>{arbres_espece}</b> du genre <b>{arbres_genre}</b> et mesure <b>{arbres_hauteurenm} mètres </b> pour une circonférence de <b>{arbres_circonferenceencm} centimètres.</b> </br> Date de plantation : {com_annee_plantation}"
const textElement2 = new TextContent();
textElement2.text = "{com_descriptif}"
// Create the ImageMediaInfoValue
let imageMediaInfoValue = new ImageMediaInfoValue({
sourceURL: "{com_url_photo1}"
});
// Create the ImageMediaInfo
let imageElement = new ImageMediaInfo({
caption: "{com_resume}",
value: imageMediaInfoValue
});
// Create the MediaContent
let mediaElement = new MediaContent({
mediaInfos: [ imageElement ]
});
arbresRemarquables.popupTemplate = {
title: "{com_nom_usuel} / {com_nom_latin}",
content : [textElement1,mediaElement, textElement2]
};
//////Labels
let labelClass = { // autocasts as new LabelClass()
symbol: {
type: "label-3d", // autocasts as new TextSymbol()
symbolLayers: [{
type: "text", // autocasts as new TextSymbol3DLayer()
material: { color: "#7B656F"},
halo : {color : "#FFF", size : "1px"},
size: 12, // Defined in points
font: { // autocast as new Font()
family: "Playfair Display",
style : "italic",
weight : "bold",
size: 12,
}
}],
verticalOffset: {
screenLength: "25px",
},
callout: {
type: "line", // autocasts as new LineCallout3D()
size: 0.2,
color: "#7B656F",
/* border: {
color: "#FDF6F0"
}*/
}
},
//labelPlacement: "above-right",
labelExpressionInfo: {
expression: "$feature.com_nom_usuel"
},
};
// Add labels to the feature layer
arbresRemarquables.labelsVisible = true;
arbresRemarquables.labelingInfo = [labelClass];
//////Rendre les autres arbres invisibles
let treeLayer = map.basemap.referenceLayers.find(function(layer){
return layer.id === "1872932aeb4-layer-48";
});
treeLayer.visible = false ;
});
});
Also see: Tab Triggers