Skip to content

Commit

Permalink
add map starting pos options
Browse files Browse the repository at this point in the history
  • Loading branch information
KatrinaTurner committed Sep 9, 2021
1 parent ce14561 commit 0a8178c
Show file tree
Hide file tree
Showing 9 changed files with 2,483 additions and 7 deletions.
2,441 changes: 2,441 additions & 0 deletions dist/components/cr.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}
],
"version": "1.0.0",
"updated": "2021-09-08"
"updated": "2021-09-09"
},
"dependencies": {
"grafanaDependency": ">=7.0.0",
Expand Down
8 changes: 7 additions & 1 deletion src/components/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ export const Canvas = (props) => {
const id = props.panelId;
const map = new NetworkMap('Map_' + id);

var thisMap = map.renderMap(props.data, props.mapData);
var thisMap = map.renderMap(
props.data,
props.mapData,
props.options.startLat,
props.options.startLng,
props.options.startZoom
);
// SUPER IMPORTANT!!! this removes the old map before rerendering
return () => {
thisMap.off();
Expand Down
5 changes: 2 additions & 3 deletions src/components/RenderMap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as d3 from './d3.min.js';
import * as L from 'components/leaflet';
import * as es from './esmap.js';
import esnetjson from './esnet.json';

export default class NetworkMap {
constructor(id) {
Expand All @@ -16,7 +15,7 @@ export default class NetworkMap {
* @param hoverColor - the color the lines will change to when hovering, set in options panel
*/

renderMap(parsedData, mapData) {
renderMap(parsedData, mapData, startLat, startLng, startZoom) {
if (!parsedData || !mapData) {
return;
}
Expand All @@ -40,7 +39,7 @@ export default class NetworkMap {
var map = L.map(this.containerID, {
zoomAnimation: false,
fadeAnimation: false,
}).setView([42, -105], 4);
}).setView([startLat, startLng], startZoom);
L.tileLayer(
'https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',
{
Expand Down
5 changes: 5 additions & 0 deletions src/components/esmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ function renderEdgeControl(g, data, ref) {
var ll = ref.leafletMap.containerPointToLatLng(L.point(d3.pointer(evt, mapDiv)));
d[0] = ll.lat;
d[1] = ll.lng;
//--- this is where we can update json????
// newjson = get current json
// find point to change
// change point to d[0], d[1]
// options.mapjson = JSON.stringify(newjson)
//--- rerender stuff
ref.update();
}
Expand Down
22 changes: 22 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ plugin.setPanelOptions((builder) => {
description: 'The color to highlight nodes that match the query',
defaultValue: 'red',
});
builder.addNumberInput({
path: 'startLat',
name: 'Starting Latitude of map',
description: 'This will be the center of the map when it loads. (numbers only)',
defaultValue: 42,
});
builder.addNumberInput({
path: 'startLng',
name: 'Starting Longitude of map',
description: 'This will be the center of the map when it loads. (numbers only)',
defaultValue: -105,
});
builder.addSliderInput({
path: 'startZoom',
name: 'Starting zoom level of map',
defaultValue: 5,
settings: {
min: 1,
max: 15,
step: 1,
},
});
builder.addSelect({
path: 'srcField',
name: 'Source Field',
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ export interface MapOptions {
srcField: string;
dstField: string;
valField: string;
startLat: number;
startLng: number;
startZoom: number;
}

0 comments on commit 0a8178c

Please sign in to comment.