IEEE.org
|
IEEE Xplore Digital Library
|
IEEE Standards
|
IEEE Spectrum
|
More Sites
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Open at RIT
My Conservation Life
Conservation360
Commits
a1b73d38
Commit
a1b73d38
authored
Apr 06, 2020
by
jedjas12
Browse files
hi anthony
parent
66bae04d
Changes
1
Hide whitespace changes
Inline
Side-by-side
salesforce/my-conservation-life/force-app/main/default/lwc/geoQuery/geoQuery.js
View file @
a1b73d38
...
@@ -9,8 +9,7 @@ import utils from 'c/utils';
...
@@ -9,8 +9,7 @@ import utils from 'c/utils';
const
DISTANCE_URL
=
utils
.
URL
+
'
assets/geometrySearch/distance
'
;
const
DISTANCE_URL
=
utils
.
URL
+
'
assets/geometrySearch/distance
'
;
const
POLY_URL
=
utils
.
URL
+
'
/assets/geometrySearch/polygon
'
;
const
POLY_URL
=
utils
.
URL
+
'
/assets/geometrySearch/polygon
'
;
// TODO import { assets, bboxAssets } from 'c/controllers';
import
{
assets
,
bboxAssets
}
from
'
c/controllers
'
;
// TODO import { markerFromAsset } from './utils';
/* L is the Leaflet object constructed by the leaflet.js script */
/* L is the Leaflet object constructed by the leaflet.js script */
/*global L*/
/*global L*/
...
@@ -22,8 +21,8 @@ export default class GeoQuery extends LightningElement {
...
@@ -22,8 +21,8 @@ export default class GeoQuery extends LightningElement {
* Starts the download for asset details and bounding box early.
* Starts the download for asset details and bounding box early.
*/
*/
connectedCallback
()
{
connectedCallback
()
{
//
this.assetsPromise = assets.find({ projectId: parseInt(this.projectId, 10) });
this
.
assetsPromise
=
assets
.
find
({
projectId
:
parseInt
(
this
.
projectId
,
10
)
});
//
this.assetsBboxPromise = bboxAssets.get(parseInt(this.projectId, 10));
this
.
assetsBboxPromise
=
bboxAssets
.
get
(
parseInt
(
this
.
projectId
,
10
));
}
}
/**
/**
...
@@ -39,6 +38,42 @@ export default class GeoQuery extends LightningElement {
...
@@ -39,6 +38,42 @@ export default class GeoQuery extends LightningElement {
* @param {CustomEvent} event
* @param {CustomEvent} event
* @param {Map} event.details - Leaflet Map of the child component
* @param {Map} event.details - Leaflet Map of the child component
*/
*/
responseGather
(
asset
)
{
this
.
assetsPromise
=
asset
;
// When the promise is fulfilled handle it
this
.
assetsPromise
.
then
(
response
=>
{
// Response should be an array of assets
console
.
log
(
response
);
// Initialize the array if need be
if
(
this
.
myAssets
===
undefined
){
this
.
myAssets
=
[];
}
// Iterate over the assets and add them to the map
let
i
;
for
(
i
=
0
;
i
<
response
.
length
;
i
++
)
{
const
a
=
response
[
i
];
// Create the map marker. Add back the offset so markers appear where the user clicked.
let
m
;
if
(
a
.
asset_type
===
"
Tree
"
)
{
m
=
L
.
marker
(
L
.
latLng
(
a
.
lat
,
a
.
lon
),
{
icon
:
baobabIcon
}).
addTo
(
map
);
}
else
{
m
=
L
.
marker
(
L
.
latLng
(
a
.
lat
,
a
.
lon
)).
addTo
(
map
);
}
// Add expanded details for if a user clicks on the marker
m
.
bindPopup
(
`
${
a
.
asset_type
}
\n\r
${
a
.
project_name
}
`
);
// // Keep a reference to the marker so we can remove it later
this
.
myAssets
.
push
(
m
);
}
});
}
onMapInitialized
(
event
)
{
onMapInitialized
(
event
)
{
// Get the leaflet map... I have been having a hard time making this a class variable...
// Get the leaflet map... I have been having a hard time making this a class variable...
const
map
=
event
.
detail
;
const
map
=
event
.
detail
;
...
@@ -96,33 +131,39 @@ export default class GeoQuery extends LightningElement {
...
@@ -96,33 +131,39 @@ export default class GeoQuery extends LightningElement {
// Send out the POST request
// Send out the POST request
this
.
assetsPromise
=
utils
.
post
(
distanceURL
.
href
);
this
.
assetsPromise
=
utils
.
post
(
distanceURL
.
href
);
// When the promise is fulfilled handle it
responseGather
(
this
.
assetsPromise
);
this
.
assetsPromise
.
then
(
response
=>
{
// Response should be an array of assets
// // When the promise is fulfilled handle it
console
.
log
(
response
);
// this.assetsPromise.then(response => {
// // Response should be an array of assets
// Initialize the array if need be
// console.log(response);
if
(
this
.
myAssets
===
undefined
){
this
.
myAssets
=
[];
// // Initialize the array if need be
}
// if( this.myAssets === undefined){
// Iterate over the assets and add them to the map
// this.myAssets = [];
let
i
;
// }
for
(
i
=
0
;
i
<
response
.
length
;
i
++
)
{
// // Iterate over the assets and add them to the map
const
a
=
response
[
i
];
// let i;
// for(i = 0; i < response.length; i++)
// Create the map marker. Add back the offset so markers appear where the user clicked.
// {
console
.
log
(
baobabIcon
);
// const a = response[i];
let
m
=
L
.
marker
(
L
.
latLng
(
a
.
lat
,
a
.
lon
),
{
icon
:
baobabIcon
}).
addTo
(
map
);
// // Create the map marker. Add back the offset so markers appear where the user clicked.
// let m;
// Add expanded details for if a user clicks on the marker
// if (a.asset_type === "Tree") {
m
.
bindPopup
(
`
${
a
.
asset_type
}
\n\r
${
a
.
project_name
}
`
);
// m = L.marker(L.latLng(a.lat, a.lon), {icon: baobabIcon}).addTo(map);
// } else {
// // Keep a reference to the marker so we can remove it later
// m = L.marker(L.latLng(a.lat, a.lon)).addTo(map);
this
.
myAssets
.
push
(
m
);
// }
}
});
// // Add expanded details for if a user clicks on the marker
// m.bindPopup(`${a.asset_type}\n\r${a.project_name}`);
// // // Keep a reference to the marker so we can remove it later
// this.myAssets.push(m);
// }
// });
}
}
if
(
type
===
'
polygon
'
||
type
===
'
rectangle
'
)
{
if
(
type
===
'
polygon
'
||
type
===
'
rectangle
'
)
{
...
@@ -165,8 +206,12 @@ export default class GeoQuery extends LightningElement {
...
@@ -165,8 +206,12 @@ export default class GeoQuery extends LightningElement {
const
a
=
response
[
i
];
const
a
=
response
[
i
];
// Create the map marker. Add back the offset so markers appear where the user clicked.
// Create the map marker. Add back the offset so markers appear where the user clicked.
let
m
=
L
.
marker
(
L
.
latLng
(
a
.
lat
,
a
.
lon
),
{
icon
:
baobabIcon
}).
addTo
(
map
);
let
m
;
if
(
a
.
asset_type
===
"
Tree
"
)
{
m
=
L
.
marker
(
L
.
latLng
(
a
.
lat
,
a
.
lon
),
{
icon
:
baobabIcon
}).
addTo
(
map
);
}
else
{
m
=
L
.
marker
(
L
.
latLng
(
a
.
lat
,
a
.
lon
)).
addTo
(
map
);
}
// Add expanded details for if a user clicks on the marker
// Add expanded details for if a user clicks on the marker
m
.
bindPopup
(
`
${
a
.
asset_type
}
\n\r
${
a
.
project_name
}
`
);
m
.
bindPopup
(
`
${
a
.
asset_type
}
\n\r
${
a
.
project_name
}
`
);
...
@@ -175,8 +220,7 @@ export default class GeoQuery extends LightningElement {
...
@@ -175,8 +220,7 @@ export default class GeoQuery extends LightningElement {
this
.
myAssets
.
push
(
m
);
this
.
myAssets
.
push
(
m
);
}
}
});
});
}
}
});
});
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment