Giter Club home page Giter Club logo

nearby-javascript's Introduction

Nearby Places JavaScript

This repo provides an example app called Nearby Places that can be used as as starter for your organizations mapping applications built with ArcGIS API 4 for JavaScript. You can use the Nearby Places as is, or extend it using the ArcGIS API for JavaScript.


Features

  • Geocoding with categories
  • Device location
  • Calculating bearing and distance
  • Automatic switch of basemap and renderer based on day or night
  • Built as a Progressive Web App

This application takes advantage of numerous technologies for development purposes. It utlizes webpack to compile and bundle the application code and other files. It is written in TypeScript and is built using React, React hooks and custom React hooks.

This application also uses Workbox for Webpack to set up service workers for the application to cache application code and files, as well as uses an appcache fallback for Internet Explorer, Edge, and Safari.

Jest is used for all unit tests.

Feel free to use this project as a starting point for your own applications!

Detailed Documentation

Read the docs for a detailed explanation of the application, including its architecture and how it leverages the ArcGIS platform, as well as how you can begin using the app right away.

Usage

  • Clone the repo and run npm install.

  • NOTE FOR WINDOWS USERS - You may need to install the Windows-Build-Tools to compile npm modules for this project. npm install --global --production windows-build-tools

  • Login to ArcGIS for Developers and register your app to create an Client ID.

  • You will need to register your application with a Client ID so that you can take advantage of the premium Directions and Routing Services from the ArcGIS Platform. It is recommended that you create one application ID for development purposes and another application ID for production deployments.

  • Once you have registered your application, copy the client id and create two files in the env/ folder.
  • env/development.env
  • env/production.env

In these files you can define the application ID for both environments for your application.

# env/development.env
ARCGIS_APP_ID=THISisMYdevelopmentID
# env/production.env
ARCGIS_APP_ID=THISisMYproductionID

The application ID will be injected into your application during the webpack build process using the dotenv-webpack plugin. Although you can whitelist your application ID to various domains, it still a good practice to not check these .env files into your git repo. The application git repo is already set up to ignore these files.

  • You will also want to provide the Portal URL for your Organization, such as "https://<MY-ORGANIZATION>.maps.arcgis.com" in the src/config.ts file.
// src/config.ts
export const appId = process.env.ARCGIS_APP_ID;

/**
 * Users Portal URL.
 */
export const portalUrl = "https://www.arcgis.com"; // default Portal URL
  • As part of the registration process, add a redirect uri for your app. Navigate to the Redirect URIs section at the bottom of the registration page and set the redirect uri as shown for development purposes. You will also want to add a redirect uri for where your application will be deployed. This redirect uri is the default redirect for https://www.arcgis.com.

For development purposes, you will want to add the following redirects to your Application ID:

  • http://127.0.0.1:8080

When you deploy your application, do not use the same Application ID for development as production. You want your Application ID to only redirect to your production website.

  • npm test - run unit tests with local chrome driver.
  • npm start - compile application and run it in a local server at http://localhost:8080/.
  • npm run build - compile application for deployment.
  • npm run serve - Run a production build of the application, but serve it up locally to see how the built app will behave.

Use npm run serve to full test that Service Workers are working correctly with webpack-dev-server self signed certificates. Refer to this article on how to run Chrome with proper flags enabled for development purposes.

Demo

application

Issues

Find a bug or want to request a new feature enhancement? Let us know by submitting an issue.

Contributing

Anyone and everyone is welcome to contribute. We do accept pull requests.

  1. Get involved
  2. Report issues
  3. Contribute code
  4. Improve documentation

MDTOC

Generating table of contents for documents in this repository was performed using the MDTOC package for Atom.

Licensing

Copyright 2018 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's LICENSE file

nearby-javascript's People

Contributors

esreli avatar gavinr avatar miketschudi avatar mikewilburn avatar mschenker avatar odoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nearby-javascript's Issues

UI Issue: difficult to discern UI elements in nearby places list.

screen shot 2019-01-11 at 3 48 22 pm

It is difficult to discern which UI elements are a part of which list item.

Because of how a list item cell is formatted, the list item subtitle (address) appears quite near to the next list item's title (name)

Please reformat this list view so that it is more easily understood which UI item belongs to which nearby place.

You could accomplish this by either:

A) Reformatting the UI elements of each list item so that the title and subtitle are closer together:

redesigned-list

B) Inserting a line between each list item.

redesigned-list-b

Clear Identify box when a new Search or Filter is ran

If I click on a feature on the map to identify it, and then I run a new Search or Filter, the Identify box doesn't close. This can be an issue if the user has filtered out the category that feature belonged too. See screenshot below. I identified a restaurant, and then I removed restaurants from my filter list. The Identify box remained despite the feature no longer being on the map.

image

Device: Microsoft Surface 3
OS: Windows 10 version 1803 build 17134
Browser: Chrome v. 71.0.3578.98

Search button timeout is very short

I'm not sure about the use case(s) for having a short timeout. I suggest bumping the Notification.tsx snackbar timeout from 3000 to something like 10000, or longer.

Handle geolocation errors

Suggestion to enhance useGeolocation.ts:

Replace these lines:

      navigator.geolocation.getCurrentPosition(({ coords }) => {
        const { latitude, longitude } = coords;
        setState({ latitude, longitude });
      });

With the following:

      // Check if geolocation is enabled
      if ("geolocation" in navigator) {
        navigator.geolocation.getCurrentPosition(({ coords }) => {
          const { latitude, longitude } = coords;
          . . .  
        }, error => {
          // handle geolocation errors
          });
      } else {
        // gracefully handle in UI when no geolocation is available
      }

Add directions type and duration

It would be nice if when the user got directions, they were told that those were walking directions, and maybe have the amount of time it would take to get there. Take a look please at the screenshot below from the Android app. Something simple like that would be great to maintain consistency between apps.

image

Search button seems to randomly disappear

As I pan the map, the Search for places box at the bottom slides up, but the SEARCH button isn't always there. About 30% of the time there is no SEARCH button.

image

Device: Microsoft Surface 3
OS: Windows 10 version 1803 build 17134
Browser: Chrome v. 71.0.3578.98

UI looks made for phones and doesn't adapt for tablets

I'm testing this app on my Microsoft Surface and the UI looks like it was designed for phones. It should adapt a little bit to not have all that blank space in the middle. See screenshot below

image

Device: Microsoft Surface 3
OS: Windows 10 version 1803 build 17134
Browser: Chrome v. 71.0.3578.98

Center the search button at bottom of map view

The Search button is currently centered at the bottom of the entire application window.
It would demonstrate a better practice to show how to center it at the bottom of just the map view.

It appears a bit oddly when it becomes offset:
image

POI returned as both type 'Food' and type 'Pizza'

I filtered the data to only show Bar or Pub and it seems the only data we have is in Central America. That doesn't seem right, could we look at the data? Is there a definition query on it maybe? And if that is what the data shows, then should we remove that category altogether?

@mikewilburn do you have access to the Android version of the app? Can we look at that and see what it's using and if this category shows a different result.

image

Map page popup issues

When logged in, there are several issues with the popup on the map result page.

To reproduce:

  1. Run app locally and log in
  2. Click on an item in the list
  3. Go back to home page/list
  4. Select another item in the list
  5. Repeat steps 2 - 4

There are several issues that I'm seeing:

  • On the very first list selection I get a valid popup that automatically opens when the map page loads:

image

  • After that sometimes the popup at the bottom of the map window doesn't inflate?

image

  • Sometimes there's neither an icon or popup?

  • And sometimes there is an icon but no popup?

image

Tests fail and app do not compile

I ran ```npm test`` and I could not get all tests to run successfully. Here is a screenshot of the error messages I am getting
image
Also, the app doesn't compile when I run npm start What do I do next to resolve this?

Apply filter doesn't honor current extent

If I pan away from my current location and then hit the SEARCH button at the bottom I get the behavior I expect: a new set of results that match the current visible extent.

However, if I pan away from my current location and then hit the Filter button and Apply a new filter, the result set doesn't match the current visible extent. Instead it matches the user's current location (blue dot).

nearby-js

Device: Microsoft Surface 3
OS: Windows 10 version 1803 build 17134
Browser: Chrome v. 71.0.3578.98

Map doesn't load on first app load

I loaded the app and got a list of nearby places (see issue #5 for screenshot). Then I clicked on the Map button and a globe flashed for a split second but then the page just went blank. I refreshed it after about 10 minutes of waiting and then it loaded. Cleared cache and retried, same behavior, the map didn't load until I refreshed it

Device: Microsoft Surface 3
OS: Windows 10 version 1803 build 17134
Browser: Chrome v. 71.0.3578.98

Recenter to selection

On larger screens with both the map and list of nearby places visible, the map will recenter and highlight the selected place, however, on smaller screens with only the list visible - if you select a place, the map opens but it doesn't highlight and recenter over the selected place.

Stumbling

I wish this app was on the JS Api pages as an example, I totally stumbled on this by accident. I am interested in using react hooks with the api.

Update UX for desktop and mobile

The app is designed as mobile-first, but I think I can make some changes so that if the browser screen size is say 900px wide, I can show the list and the map at the same time.

Fix incoming.

Double tap on touchpad doesn't trigger zoom

This may be a JS API issue, but I just noticed that if I double tap on the touchpad of my surface, the app looks like it's trying to do an Identify rather than zoom. This only happens with a light double tap. If I do a heavy double tap where the touchpad is pushed until it clicks, the zoom works every time.

Device: Surface Pro 3
OS: Windows 10 v 1803 build 17134
Browser: Google Chrome v 71.0.3578.98

From Surface documentation: Press the touchpad firmly to click. A quick tap is interpreted as a touch gesture.

On mobile devices the map view becomes unresponsive to click or double click for a second visit or thereafter

When the map view is visited the second time the view becomes unresponsive to clicks, double clicks or taps. This may be related to #14 Double tap on touchpad doesn't trigger zoom.

To reproduce,

  1. load the app on a mobile device (or chrome responsive view)
  2. click on a list item to navigate to the map view
  3. click or double click or tap....view/map responses.
  4. go back to the list view and click some other item or simply navigate back to the map view
  5. the view stops responding

I have reverted back to JS API version 4.11 and this issue goes away but want to use the latest and greatest JS API (>= 4.14). It also fails with 4.15 as well.

1
2
3
4

Any help is appreciated. Thanks.

Consolidate environment vars

Seems like it would be more consistent and cleaner to consolidate all the configuration variables in one place under /env. My suggestion is to have the developement.env and production.env files already created.

Add the following to both .env files:

ARCGIS_APP_ID=THISisMYdevelopmentID

And, move the following from config.ts and make them environment vars as well:

  • DEFAULT_WORKER_URL
  • portalUrl
  • geocodeURL

Should the app work even if user doesn't allow it to use their location?

When the app starts, if I decline the prompt asking me to share my location, the app no longer works. It loads a map centered on Palm Springs but search and filtering doesn't work.

image

For one, I feel the app should somehow communicate to the user that they can't do anything because they haven't enabled location.

But the question is, should the app still work? Other than directions, which need the current location, I don't see why the rest of the functionality should be restricted. @mikewilburn @fallsdownhill thoughts? How does the Android app behave?

Not sure how filter is supposed to work?

How is the filter supposed to work? It seems like it reorders the list somewhat inconsistently. Is it supposed to only display results based on that keyword?

Here's an example where I selected filter by "Pizza"

image

And, the same list when filtered by "Hotel"

image

This is filtered by "Coffee Shops", the hotel is still at the top of the list:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.