Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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('assets/data/sickness-data.geojson'); } ... --------------------------------------- map-sidebar-mode.enum.ts export enum MapSidebarMode { SINGLE_TRACT_BREAKDOWN = 'single-tract-breakdown', SINGLE_ZIPCODE_BREAKDOWN = 'single-zipcode-breakdown', MULTI_TRACT_BREAKDOWN = 'multi-tract-breakdown', MULTI_ZIPCODE_BREAKDOWN = 'multi-zipcode-breakdown', FEATURE_POINT_SUMMARY = 'feature-point-summary'

----------------------------------------

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

8. Measure the effectiveness of the succession planning process.

Answered: 1 week ago

Question

7. Determine what feedback is provided to employees.

Answered: 1 week ago