How do you know for obtaining the best line of Arcgis ClosestFacilityParameters which id belongs to? - gis

How do you know for obtaining the best line of Arcgis ClosestFacilityParameters which id belongs to?
I want to set the id of the best route and externally set the properties of the route with id
const facilities = [
{
id: "a",
center: [-122.67484, 45.52087],
},
{
id: "b",
center: [-122.68365, 45.52327],
},
{
id: "c",
center: [-122.66406, 45.52378],
},
{
id: "d",
center: [-122.6631, 45.52093],
},
{
id: "e",
center: [-122.66208, 45.5197],
},
{
id: "f",
center: [-122.66247, 45.51845],
},
{
id: "g",
center: [-122.66299, 45.51827],
},
];

Related

Can you animate circles on mapbox, and also, just have hollow circles

I know you can animate circles on google maps , see example
http://jsbin.com/nuwem/1/edit?html,output
.....But can you do the same thing on Mapbox
I am creating a live earthquake map www.livehazards.com. Each earthquake mag is respresent by a circle
I would just like the outline of the circle and to be able to animate it.
I have tried using circle-stroke for just the outline but it did not work
Thanks
To animate your circle you can simply change its paint property several times: map.setPaintProperty('yourmarker', 'circle-radius', 20)
If you only want the circle outline, set "circle-opacity":0 and "circle-stroke-width": 1.
Codepen
const map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v9',
center: [ 2.35, 48.85 ],
zoom: 3
});
map.on('load', () => {
let radius = 1;
map.addLayer({
"id": "points",
"type": "circle",
// Create the marker
"source": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [ 2.35, 48.85 ]
}
}]
}
},
// Draw the circle
"paint": {
"circle-opacity": 0,
"circle-stroke-width": 1,
"circle-stroke-color": "#000",
"circle-radius": radius,
"circle-radius-transition": {
"duration": 0
}
}
});
// Animate the circle
setInterval(() => {
map.setPaintProperty('points', 'circle-radius', radius);
radius = ++radius % 30;
}, 50);
});
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v9',
center: [ 2.35, 48.85 ],
zoom: 3
});
map.on('load', function() {
let radius = 1;
map.addSource("earthquakes", {
type: "geojson",
data: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_day.geojson",
});
map.addLayer({
"id": "earthquake-layer",
"type": "circle",
"source": "earthquakes",
"paint": {
"circle-opacity": 0.4,
"circle-color": "#830300",
"circle-stroke-width": 2,
"circle-stroke-color": "#fff",
"circle-radius": {
"property": "mag",
"base": 2.5,
"stops": [
[{zoom: 0, value: 2}, 1],
[{zoom: 0, value: 8}, 40],
[{zoom: 11, value: 2}, 10],
[{zoom: 11, value: 8}, 2400],
[{zoom: 20, value: 2}, 20],
[{zoom: 20, value: 8}, 6000]
"circle-radius-transition": {
"duration": 0
}
]
}
}
});
setInterval(() => {
map.setPaintProperty('eaarthquake-layer', 'circle-radius', radius);
radius = ++radius % 30
}, 50);
});

Loading and using JSON for Cytoscape.js

Context
I want to use cytoscape.js for visualizing graphs. While I am capable with a myriad of languages (C++, Mathematica, R, etc), I am new to Javascript, JSON, HTML, and CSS. Thus it would be favorable to learn these languages through this use case (implementing graphs with cytoscape.js). Please keep this in mind in your answer.
I have previously asked how to [remotely load cytoscape.js and how to get graphs display (requires a div). Since then I have created a script that turns a graph as represented in one of the other languages I use, into the JSON format indicated here. While I can just copy-paste all of this directly into my program, for large networks that is clearly a poor way to implement it. An example of my script's output is at the bottom of this.
Question
Given a JSON object/file(?) how can I do the following:
load it into cytoscape.js without copy-pasting the code.
referencing it once loaded. (e.g. basic explanation of how JSON syntax for use in cytoscape.js)
Script Output
cytoscape({
container: document.getElementById('cy'),
elements: [
{// node Node 1
group: 'nodes',
data: {
id: 'Node 1'
},
selected: false,
selectable: true,
locked: false,
grabbable: true,
selectable: true,
},
{// node Node 2
group: 'nodes',
data: {
id: 'Node 2'
},
selected: false,
selectable: true,
locked: false,
grabbable: true,
selectable: true,
},
{// node Node 3
group: 'nodes',
data: {
id: 'Node 3'
},
selected: false,
selectable: true,
locked: false,
grabbable: true,
selectable: true,
},
{// edge 1_2
group: 'edges',
data: {
id: '1_2',
source: '1',
target: '2'
}
},
{// edge 2_3
group: 'edges',
data: {
id: '2_3',
source: '2',
target: '3'
}
},
{// edge 3_1
group: 'edges',
data: {
id: '3_1',
source: '3',
target: '1'
}
}
],
style: [
{
selector: 'node',
style: {
'content': 'data(id)'
}
}
]
});
<head>
<title></title>
<script src="js/vendor/cytoscape.min.js"></script>
<script src="js/vendor/jquery.min.js"></script>
</head>
<style>
#cy {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
}
</style>
<body>
<div id="cy"></div>
<script>
$.getJSON("cyto.js", function (data) {
//console.log(data);
var cy = cytoscape({
container: document.getElementById('cy'),
elements: data,
style: [
{
selector: 'node',
style: {
'label': 'data(label)',
'width': '60px',
'height': '60px',
'color': 'blue',
'background-fit': 'contain',
'background-clip': 'none'
}
}, {
selector: 'edge',
style: {
'text-background-color': 'yellow',
'text-background-opacity': 0.4,
'width': '6px',
'target-arrow-shape': 'triangle',
'control-point-step-size': '140px'
}
}
],
layout: {
name: 'circle'
}
});
});
</script>
</body>
in cyto.js you can input valid JSON data, for example
{
"nodes": [
{
"data": {"id": "a", "label": "Gene1"}
},
{
"data": {"id": "b", "label": "Gene2"}
},
{
"data": {"id": "c", "label": "Gene3"}
},
{
"data": {"id": "d", "label": "Gene4"}
},
{
"data": {"id": "e", "label": "Gene5"}
},
{
"data": {"id": "f", "label": "Gene6"}
}
],
"edges": [
{
"data": {
"id": "ab",
"source": "a",
"target": "b"
}
},
{
"data": {
"id": "cd",
"source": "c",
"target": "d"
}
},
{
"data": {
"id": "ef",
"source": "e",
"target": "f"
}
},
{
"data": {
"id": "ac",
"source": "a",
"target": "d"
}
},
{
"data": {
"id": "be",
"source": "b",
"target": "e"
}
}]
}
Let's presume you have a json file in the same folder as your 'index.html', and your server is running. First request the json file via a http request (using plain javascript or jquery ).
If your json file has the same format as the elements properties, you can just parse it to a javascript object and set it. E.g.
var myObject = {};
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
myObject = JSON.parse(this.responseText);
initCytoscape();
}
};
xhttp.open("GET", "myJson.json", true);
xhttp.send();
function initCytoscape() {
cytoscape({
container: document.getElementById('cy'),
elements: myObject
});
}
if the json property is different than cytoscape's format, then you have to programatically convert it.

Google Map position Right_Center Not working

I am using Google Map and want the position to RIGHT_CENTER. But it is not working for me. Please help me to solve this. Thank you.
Code:
var contact = { "lat": "****", "lon": "***" }; // Change a map coordinate here!
try {
var mapContainer = $('#map');
mapContainer.gmap3({
action: 'addMarker',
latLng: [contact.lat, contact.lon],
map: {
center: [contact.lat, contact.lon],
zoom: 17,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.RIGHT_CENTER // This is not working
},
},
}, { action: 'setOptions', args: [{ scrollwheel: true }] } ); }
Looks like you are using gmap3 jquery plugin. You should specify all map options in options property there (I guess other options dont work as well), see here.
Like this:
var mapContainer = $('#map');
mapContainer.gmap3({
marker:{
latLng: [45,-10],
},
map: {
options: {
center: [45,-10],
zoom: 5,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.RIGHT_CENTER // This is not working
}
}
},
}, { action: 'setOptions', args: [{ scrollwheel: true }] } );
see demo

Sort a store data based on inner JSON field sencha

i have a json in the following format:
{
"collection": [
{
"id": 4,
"tickets": [
{
"price": 40,
},
{
"price": 50,
}
],
},
{
"id": 1,
"tickets": [
{
"price": 10,
},
{
"price": 15,
}
]
},
]
}
STORE:
Ext.define("myProject.store.ABCs", {
extend: "Ext.data.Store",
config: {
model: "myProject.model.ABC",
autoLoad: false,
proxy: {
type: "ajax",
url: '', //myURL
reader: {
type: "json",
rootProperty: "collection", // this is the first collection
},
},
}
});
For this particular JSON i created the models as:
Ext.define("myProject.model.ABC", {
extend: "Ext.data.Model",
config: {
idProperty: "id",
fields:[
{name: "id", type: "int" },
],
hasMany: [
{
model: "myProject.model.XYZ",
name: "tickets",
associationKey: "tickets",
},
],
}
});
And second model as:
Ext.define("myProject.model.XYZ", {
extend: "Ext.data.Model",
config: {
// idProperty: "id",
fields:[
{name: "inner_id", type: "int" },
],
belongsTo: 'myProject.model.ABC'
}
});
This particular code creates a store and populates the models correctly.
var store = Ext.getStore('ABCs');
Now i want to sort this store based on store.tickets().getAt(0).get('price') that is sort the ABC records based on XYZ's first price property.
In the above json. ABC Records will be: [{id:4}, {id:1}]
But since first price in XYZ (40 > 10), i want to sort them and create [{id:1}, {id:4}]
Take a look at the Ext.util.Sorter class, where you can set a sorterFn. See the example at the top of the page - you should be able to simply write the logic for sorting records the way you describe.

KendoUI Line Chart with 500+ values on datasource is lazy loaded

I am using Kendo UI Line chart from Web Dataviz package for generate a Graph with 500+. but the load of the graph is too lazy. It takes like 25 seconds for the graph to be generated.
I am using a date for Category Axis and a Decimal Value for the serie with a odata datasource.
Can I optimize the load time of the graph?
$("#chart").kendoChart({
theme: $(document).data("kendoSkin") || "default",
dataSource: {
type: "odata",
transport: {
read: crudServiceBaseUrl + "/Odata/TestODataService.svc/EGauges"
},
serverFiltering: true,
serverSorting: true,
sort: { field: "DateData", dir: "asc"},
filter: [
{field: "From", operator: "eq", value: 422 },//400+
{ field: "Id", operator: "eq", value: parseInt(id) },
{ field: "Intervalo", operator: "eq", value: 23 },
{ field: "Tipo", operator: "eq", value: 'm' }
],
title: {
text: ""
},
legend: {
position: "bottom"
},
seriesDefaults: {
type: "area"
},
series: [{
field: "Value",
name: "Value"
}],
categoryAxis: {
field: "DateData",
labels: {
visible: false,
rotation: -90
}
},
axisDefaults: {
visible: true,
majorGridLines: { visible: false }
},
tooltip: {
visible: true
}
});
Here is how the odata service is returning data:
jQuery1704278529312834345_1357310335401({"d" : {
"results": [
{
"__metadata": {
"uri": "http://localhost/Prosol.Web/Odata/TestODataService.svc/EGauges(18)",
"type": "TestOpenErpInterfaz.Web.TestEntityDataSource_EGauge"
},
"EGaugeID": 18,
"From": 422,
"Id": 18,
"Tipo": "m",
"Intervalo": 23,
"DateData": "\/Date(1357310820000)\/",
"Value": "3.72",
"TotalKw": "0",
"TotalCosto": "0.00",
"TotalKwGen": "203.23999999999999999999999999",
"TotalCostoGen": "16.259199999999999999999999999",
"FechaDisplay": "Ene 4, 2013 14:47"
},........
], "__count": "421"
}
})
Finally I Use FlotCharts, For some reason the KendoUI Chart laoad data very lazy... I use Kendo Ui Datasource for read data from Web Service and load on FloatChart...
http://www.flotcharts.org/
This is simple, fast, and freeware