Query on feature layer and draw a point on feature with matching OBJECTID - json

I have a JSON file with data as:
[{
"data": [{
"assetID": 1,
"colorCode": 3
}, {
"assetID": 2,
"colorCode": 1
}, {
"assetID": 3,
"colorCode": 4
}, {
"assetID": 4,
"colorCode": 2
}, {
"assetID": 5,
"colorCode": 3
}, {
.
.
.
"assetID": 1000,
"colorCode": 2
}]
}]
where,
assetID is unique (upto 1000)...
colorCode is a random number between 1 to 4... and each colorCode corresponds to any unique color.Like,
colorCode 1, color Green...
colorCode 2, color Orange...
colorCode 3, color Yellow...
colorCode 4, color Red...
I have created a simple webmap in ArcGIS online with one tile layer and one feature layer. Now, I have to write a code in JS where when the feature's OBJECTID matches the assetID, a point should be drawn there in the color corresponding to the colorCode on the map.
Like, for assetID 1 colorCode is 3, so at feature with OBJECTID 1 on the map, a point should be drawn there in green color and so on.
I have created the JSON file and the webmap, but I am really new to all this ArcGIs and dojo and I am really at a loss where to proceed next.

How are you hosting the application. Is it just a webmap in ArcGIS online or you using WebAppBuilder or you have a custom web application. All these factor determine whether you can customize your map or not.
Also, your layer is it a FeatureLayer or a Map Service. or just graphic data. If it is graphic data its lot easier to make the customization. Let me know more details so that I can provide you with specific answer.
Take a look at this post https://gis.stackexchange.com/questions/50558/customizing-arcgis-online-application-template-and-uploading-it-back-to-arcgis-o
it provides information on how you can customize webmap.
Hope this was helpful.

Related

Autodesk Forge PDF Viewer and Measuring

I am working on an app that needs to calculate measures like areas and length etc. Lucky today by using Autodesk Forge viewer we can do that. I had looked into this blog post [enter link description here][1]
and as well to the docs [enter link description here][2]
[1]: https://aps.autodesk.com/blog/fast-pdf-viewingmarkup-inside-forge-viewer
[2]: https://aps.autodesk.com/en/docs/viewer/v7/reference/Extensions/MeasureExtension/
I am looking for a way to insert the measure values into my database, where I can view it again when I want or reload the page (not lose it) similarly with Markup with callouts and text.
Lastly, I am wondering about how much does it costs to translate the pdfs files using Forge?
thanks
You can retrieve the array with objects related with the measurements done with the line:
NOP_VIEWER.getExtension('Autodesk.Measure').measureTool.getMeasurementList()
You can store the result in your DB, together with viewstate and additional info such as urn and viewable guide.
To restore it, you can first activate the tool
NOP_VIEWER.getExtension('Autodesk.Measure').activate()
Then set the measurement list using the values you read from the DB
NOP_VIEWER.getExtension('Autodesk.Measure').measureTool.setMeasurements(listMeasurements)
Where listMeasurements will be something like:
var listMeasurements = [
{
angle: "0.0 °",
arc: "0.0 mm",
area: "0.0 mm²",
deltaX: "1569.7 mm",
deltaY: "6463.7 mm",
deltaZ: "162.0 mm",
distance: "6653.6 mm",
from: "Vertex",
location: "X: 0.0 mm\nY: 0.0 mm\nZ: 0.0 mm",
picks: [
{intersection: {x:43.5168342590332,y:-60.37924575805664,z: 8.858267784118652}, modelId: 2, viewportIndex2d: null, snapNode: 2587},
{intersection: {x: 38.367037573210276,y: -39.17272345572108,z: 8.32677173614502}, modelId: 2, viewportIndex2d: null, snapNode: 3521}
],
precision: 1,
text: "",
to: "Vertex",
type: "Distance",
unitType: "mm"
}
]
Now, you can deactivate it with one line of code
NOP_VIEWER.getExtension('Autodesk.Measure').deactivate()
Instead of using NOP_VIEWER, refer to your viewer instance through the variable defined in your code

Hovering on one sentence should highlight matching sentence in another panel in Angular

I have 2 different JSON arrays displayed separately using a simple *ngFor loop on the same page. Ex-
json1: [ {
"order": 1,
"similarity": 0.82,
"sentence": "I would like to speak with :name:.",
"matching_sentence": "Hello, I would like to speak with Luke.",
"matching_line": 0
}]
json2: [ {
"order": 0,
"similarity": 0.82,
"sentence": "Hello, I would like to speak with Luke.",
"matching_sentence": "I would like to speak with :name:.",
"matching_line": 1,
"channel": 1,
"timeFrom": 15,
"timeTo": 20
}]
So, order property from json1 matches matching_line property of json2 and vice versa. So, what I need to achieve is that on mouse hover of json1, json2 should also be highlighted and on mouse hover of json2, json1 should also be highlighted.
This code is written in Angular 11 so, any solution whether it is by css or typescript is welcome.
You can achieve it using mouse enter leave events and keeping track of the active class
<div
*ngFor="let item of json1"
[ngClass]="{'highlight': item.order === activeHover}"
(mouseenter)="onHoverChange(item.order)"
(mouseleave)="onHoverChange(null)">
{{item.sentence}}
</div>
<div
*ngFor="let item of json2"
[ngClass]="{'highlight': item.matching_line === activeHover}"
(mouseenter)="onHoverChange(item.matching_line)"
(mouseleave)="onHoverChange(null)">
{{item.sentence}}
</div>
// in ts file
onHoverChange(value: number | null) {
this.activeHover = value;
}
Running sandbox link

Power BI custom theme .json - multiple series customization

I've been tinkering with .json file to create my own custom theme, however I am stuck on multiple choice setting. Example:
Area chart -> Format -> Data labels - > here I can customize the general setting for data labels, but what I would like to set up, is the "CUSTOMIZE SERIES" for each of the series. That is, I would like to have black text label color for the first serie, yellow for the second etc.
Below is the image from power bi for the category I am trying to customize:
Customize series in Power BI
Code for these labels:
"labels": [{
"show": true,
"color": {
"solid": {
"color": "#333333"
}
},
"labelPosition": "Under",
"fontSize": 14,
"fontFamily": "Arial",
"labelDensity": 30,
"showAll": true,
"enableBackground": true,
"backgroundTransparency": 70
What this .json code achieves, is that it sets up only the general settings for all the series. That is all series will have font size 14, font Arial, background transparency 70% etc. I would like to somehow index these series, so when this .json theme gets imported into power bi the first serie would have the customized settings that I've set up, second the same etc. E.g.:
"labelPosition": "Under",
"fontSize": 14,
"fontFamily": "Arial",
"labelDensity": 30,
"showAll": true,
"enableBackground": true,
Above are the general settings for all of the series, below would be the customized series
1. serie --->>>
"backgroundTransparency": 70
2. serie ---->>>
"backgroundTransparency": 60
3. series etc..

amchart separate bullets individually

I am creating a simple time-based data plot using amcharts with has 5 values, its working great but every time there is 2 or more readings with the same value it stack up and only 1 bullet is visible, i tried to create a custom bullet but still no luck.
Is there a way to separate the bullets individually just to make it presentable.
Below is my code.
{
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#2980b9",
"bulletSize": 19,
"customBulletField": "bullet",
"id": "reading_4",
"lineThickness": 0,
"title": "reading_4",
"showHandOnHover": true,
"valueField": "column-8",
"balloonText": "<div style='margin:5px; font-size:12px;'>Reading 4: <b>[[value]]</b></div>",
"visibleInLegend": false,
},
Is there away to make it like below

Mapbox - What are my layer ID's?

I'm new to using Mapbox.
I'm trying to add a new layer to my map that is above the water layer but below labels.
map.addLayer({
'id': 'maine',
'type': 'fill',
'source': 'maine',
'layout': {},
'paint': {
'fill-color': '#088',
'fill-opacity': 0.8
}
}, 'water');
(This code was taken from some example code from Mapbox.)
Right now, this creates a layer that is below the water layer and the labels. However, I can't figure out what layer ID would bring it above the water layer.
This is the stylesheet I'm using:
mapbox://styles/mapbox/light-v9
How do I find the other valid layer ID's for this style sheet? I've tried 'streets', 'roads', 'road', 'land', etc, but nothing has worked. I thought this link included all the layer names:
https://www.mapbox.com/studio/styles/mapbox/light-v9/
but the only one that keeps my new layer from just being on top of everything is 'water'. Help!
You can retrieve style specifications from the styles api.
For example to get all the layer_ids on the light-v10 style you could do this in python:
import requests
for layer in requests.get('https://api.mapbox.com/styles/v1/mapbox/light-v10?access_token=pk.eyJ1IjoiYmNrb2hhbiIsImEiOiJja2Zvamc4ejcyZjRxMzFwMXNwcGIxdDVlIn0.KdUOuJFIaV4eCzq94AgMGw').json()['layers']: print(layer['id'])
Which yields:
land
landcover
national-park
landuse
water-shadow
waterway
water
hillshade
land-structure-polygon
land-structure-line
aeroway-polygon
aeroway-line
building-outline
building
tunnel-street-minor-low
tunnel-street-minor-case
tunnel-primary-secondary-tertiary-case
tunnel-major-link-case
tunnel-motorway-trunk-case
tunnel-construction
tunnel-path
tunnel-steps
tunnel-major-link
tunnel-pedestrian
tunnel-street-minor
tunnel-primary-secondary-tertiary
tunnel-motorway-trunk
road-pedestrian-case
road-minor-low
road-street-low
road-minor-case
road-street-case
road-secondary-tertiary-case
road-primary-case
road-major-link-case
road-motorway-trunk-case
road-construction
road-path
road-steps
road-major-link
road-pedestrian
road-minor
road-street
road-secondary-tertiary
road-primary
road-motorway-trunk
road-rail
bridge-pedestrian-case
bridge-street-minor-low
bridge-street-minor-case
bridge-primary-secondary-tertiary-case
bridge-major-link-case
bridge-motorway-trunk-case
bridge-construction
bridge-path
bridge-steps
bridge-major-link
bridge-pedestrian
bridge-street-minor
bridge-primary-secondary-tertiary
bridge-motorway-trunk
bridge-rail
bridge-major-link-2-case
bridge-motorway-trunk-2-case
bridge-major-link-2
bridge-motorway-trunk-2
admin-1-boundary-bg
admin-0-boundary-bg
admin-1-boundary
admin-0-boundary
admin-0-boundary-disputed
road-label
waterway-label
natural-line-label
natural-point-label
water-line-label
water-point-label
poi-label
airport-label
settlement-subdivision-label
settlement-label
state-label
country-label
I would just add a note of caution that the layer ids for the default styles can change significantly version to version.
You can experiment in Mapbox.com/studio by adding your maine tile set into a new style, then you can move the layer interactively to experiment and proof the effect that you want.
The second parameter for addLayer is before, so your maine source should've gone before the water layer. See the docs on addLayer for details
https://www.mapbox.com/mapbox-gl-js/api/#Map#addLayer
The names of the layers are identified by "id" in the Style.json.
You can find the names of the layers by going to the link you posted
https://www.mapbox.com/studio/styles/mapbox/light-v9/
there you will see a nice visualization of the layer ids from Mapbox.
The water layer is near the bottom of the layers stack of the Mapbox light style.
Here are the layers with water in the "id.
"id": "waterway-river-canal",
"id": "water shadow",
"id": "water",
"id": "waterway-label",
"id": "water-label",
Your layer ID can be found by opening your map in Mapbox Studio. If you go to View style details (the box with an arrow in the top right corner of the left hand window, it will reveal all the layers.