Question
Using Typescript language in Visual Studio how can I change static code to a non-static code? Below is a portion of my code since I'm
Using Typescript language in Visual Studio how can I change static code to a non-static code? Below is a portion of my code since I'm unable to post the rest. In my scenario, I'm working on trying to get a 'sickness-data.geojson' file that contains these fake zipcodes and a few data. Note: The bolded titles are names of my files that associate with this portion of the code: I did try this method but the code did not work. The error it gave me was that 'sickness-data.geojson' module was not found.
string1: string | undefined; get38002CC(data: MapSidebarData): string | undefined { let string1; const sicknessData = require('sickness-data.geojson'); for(let i = 0; i < sicknessData.features.length; i++) { if (sicknessData.features[i].properties.Zip == data.layerFeatureData!.id) { break; } else { string1 = undefined; } } return string1; }
---------------------------------------
geo-tract.service.ts
import {Injectable} from '@angular/code'; import {HttpClient} from '@angular/common/http'; import {GeoJSONObject} from '@../types/geo';
@Injectable({ providedIn: 'root' }) export class GeoTractService { constructor(private http: HttpClient) { } ...
getSicknessFeatures() { return this.http.get
----------------------------------------
sickness-data.geojson
{ "type": "FeatureCollection", "name": "SicknessData", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::4269" } }, "features": [ { "type": "Feature", "properties": { "Sickness Vaccination, Number of Children < 18yrs with at least one dose, as of 9\/17\/2018": "1234", "Sickness Vaccination, Percent of Children < 18yrs with at least one dose (%), as of 9\/17\/2018": "12.3", "Latitude": 12.345678, "Longitude": -12.345678, "Zip": "12345 }, "geometry": { "type": "Point", "coordinates": [ -12.345678, 12.345678 ] } },
{ "type": "Feature", "properties": { "Sickness Vaccination, Number of Children < 18yrs with at least one dose, as of 9\/17\/2018": "4321", "Sickness Vaccination, Percent of Children < 18yrs with at least one dose (%), as of 9\/17\/2018": "43.2", "Latitude": 87.654321, "Longitude": -87.654321, "Zip": "54321 }, "geometry": { "type": "Point", "coordinates": [ -87.654321, 87.654321 ] } },
---------------------------------------- ***(THIS IS THE PORTION I NEED TO CHANGE TO NONSTATIC)***
map-sidebar.components.ts
...
string1: string | undefined;
get38002CC(data: MapSidebarData): string | undefined{ if(data.layerFeatureData!.id == '12345'){ return '2787'; } else if (data.layerFeatureData!.id == '87654'){ return '1184'; }
else{ return this.string1; } }
get38002CCP(data: MapSidebarData): string | undefined{ if(data.layerFeatureData!.id == '12345'){ return '12.3%'; } else if (data.layerFeatureData!.id == '87654'){ return '3.21%'; }
else{ return this.string1; } }
...
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started