Skip to content

Commit

Permalink
popup uses data based on input address
Browse files Browse the repository at this point in the history
  • Loading branch information
mmt456 committed May 31, 2024
1 parent 183af07 commit a88d4ca
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"jsonwebtoken": "^8.5.1",
"leaflet": "^1.7.1",
"leaflet-geosearch": "^3.7.0",
"parse-address": "^1.1.2",
"prettier": "^2.5.1",
"qrcode.react": "^1.0.1",
"react": "^17.0.2",
Expand Down
1 change: 1 addition & 0 deletions src/parse-address.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'parse-address';
45 changes: 43 additions & 2 deletions src/vis/MeasurementMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MapType } from './MapSelectionRadio';
import { API_URL } from '../utils/config';
import * as L from 'leaflet';
import * as d3 from 'd3';
import * as parser from 'parse-address';
import {
siteMarker,
siteSmallMarker,
Expand Down Expand Up @@ -37,8 +38,43 @@ function cts(p: Cell): string {

// print results of user search event to console
function searchEventHandler(result: any): void {
//var url = "1410 NE Campus Pkwy, Seattle, WA 98195";
console.log(result);
var addressLabel = result.location.label;
console.log(addressLabel);
// var parser = require("parse-address");
var parsedAddr = parser.parseLocation(addressLabel);
console.log("hello 1");
console.log(parsedAddr);

var city = result.location.raw.address.city;
if (city == null) {
city = result.location.raw.address.town;
}
var post_direction = parsedAddr.suffix;

if (post_direction == null) {
post_direction = parsedAddr.prefix;
}

var postcode = result.location.raw.address.postcode;
var state = result.location.raw.address.state;
var endPoint = "http://127.0.0.1:8000/"; // server
var url = endPoint
+ "?state=" + state
+ "&cityname=" + city
+ "&primary=" + parsedAddr.number
+ "&street_number=" + parsedAddr.street
+ "&st=" + parsedAddr.type
+ "&post_direction=" + post_direction
+ "&zip_5=" + postcode;
// + "&zip_9=" + "3207";
console.log(url);


const xhr = new XMLHttpRequest();
xhr.open('GET', "http://127.0.0.1:8000/?state=va&cityname=arlington&primary=3109&street_number=9th&st=St&post_direction=N&zip_5=22201&zip_9=2024");
//xhr.open('GET', "http://127.0.0.1:8000/?state=va&cityname=arlington&primary=3109&street_number=9th&st=St&post_direction=N&zip_5=22201&zip_9=2024");
xhr.open('GET', url);
xhr.onload = function() {
console.log("200 check");
console.log(xhr.status);
Expand Down Expand Up @@ -195,7 +231,12 @@ const MeasurementMap = ({
setLLayer(L.layerGroup().addTo(_map));

const search = new (GeoSearchControl as any)({
provider: new OpenStreetMapProvider(),
provider: new OpenStreetMapProvider({
params: {
addressdetails: 1,
}

}),
style: 'bar', // optional: bar|button - default button
showPopup: true,
marker: {
Expand Down

0 comments on commit a88d4ca

Please sign in to comment.