Skip to content

Instantly share code, notes, and snippets.

def custom_dc(conn, airports):
new_list = {}
i = 0
json = []
#since some country has hundreds of airports, which would cause 414 error
#separate the request to small pieces
if len(airports) < 20:
for i in range(len(airports)):
new_list["source[{}]".format(i)] = airports.loc[i, 'Vertex_ID']
def nearby_airport(conn, city, distance, maxHops):
#get geo info from input city
geolocator = Nominatim(user_agent="hackathon")
location = geolocator.geocode(city)
if not location:
st.sidebar.error("City not found!")
return
lat = location.latitude
lng = location.longitude
import React, { useEffect, useRef, useState, Fragment } from 'react';
import './Map.css';
import Airport from './model/Airport.model';
import Dropdown from 'react-dropdown';
import 'react-dropdown/style.css';
import { plainToClass } from "class-transformer";
import { Button, Input, CircularProgress, Card, Grid, InputLabel, Paper } from '@material-ui/core';
import { Alert, AlertTitle } from '@material-ui/lab';
interface IMap {
const onSearchBtnClick = async () => {
//check whether source or terminal is defined
if (start === undefined || terminal === undefined) {
setError("Please select a start point or a terminal!")
return;
}
console.log(start.id === terminal.id);
if (start.id === terminal.id) {
setError("Start point and terminal are same!");
return;
@Chico-Chen
Chico-Chen / addMarker.tsx
Last active April 2, 2021 11:25
markers
//when points change, draw marker on map
const addMarkers = (): void => {
if (points) {
points.map(marker => {
addMarker(marker);
});
map?.fitBounds(bounds);
map?.panToBounds(bounds);
}
};
import React, { useEffect, useRef, useState } from 'react';
import './Map.css';
interface IMap {
mapType: google.maps.MapTypeId,
mapTypeControl?: boolean,
countries: string[],
}
type GoolgeLatLng = google.maps.LatLng;
import {
Streamlit,
StreamlitComponentBase,
withStreamlitConnection
} from "streamlit-component-lib";
import { ReactNode} from "react";
import Map from './MapComponent';
class MainComponent extends StreamlitComponentBase {
import React, { useEffect, useRef, useState } from 'react';
import './Map.css';
interface IMap {
mapType: google.maps.MapTypeId,
mapTypeControl?: boolean,
countries: string[],
}
type GoolgeLatLng = google.maps.LatLng;
const express = require('express'),
bodyParser = require('body-parser'),
port = process.env.port || 3030,
tgjs = require('tigergraph.js'),
cred = require('./config');
const app = express();
app.use(bodyParser.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', "*");
const cred = {
'HOST': 'YOUR_HOST',
"PASSWORD": "YOUR_PASSWORD",
"SECRET": "SECRET",
"TOKEN": "TOKEN",
}
module.exports = cred;