Code Monkey home page Code Monkey logo

Comments (5)

Waidhoferj avatar Waidhoferj commented on August 12, 2024

3 hrs

from csc-308-309-project.

Waidhoferj avatar Waidhoferj commented on August 12, 2024

Inputting data into a GeoJSONLayer is more performant than using individual pins on the map. Simple GeoJSON for our artwork could look like this:

{
"type": "FeatureCollection",
"features" : [
{
      "type": "Feature",
      "id": 1,
      "geometry": {
        "type": "Point",
        "coordinates": [12, 23]
      },
      "properties": {
       artworks: [...]
      }
    }
]
}

Where:

  • A Feature is just an object that goes on the map
  • The feature collection is a list of all the artwork radius features
  • Geometry is where the location and object type is stored (stuff that will determine placement on the map)
  • Properties aren't shown on the map, but can be accessed when the user interacts with the element.

Until we can grab data from the backend, you can put this data in a art-areas.json file and import it into your React component.

from csc-308-309-project.

Waidhoferj avatar Waidhoferj commented on August 12, 2024

Before displaying this on the map, you'll need an api token from MapBox. You can sign up here (totally free)

Once you have your default map set up, you can display the geojson like this:

import artAreasJSON from "art-areas.json"

...

<Map>
<GeoJSONLayer
          data={artAreasJSON}
          fillLayout={{ visibility: "visible" }}
          fillPaint={{
            "fill-color": "blue",
            "fill-opacity": 0.4,
          }}
        />
...
</Map>

``

from csc-308-309-project.

Waidhoferj avatar Waidhoferj commented on August 12, 2024

To respond to click events, add this listener to the geojson layer:

circleOnClick={handleClick}
...
function handleClick(e) {
// Respond to click
}

Then you can pass the targeted latitude and longitude to the compass.

from csc-308-309-project.

gwholland3 avatar gwholland3 commented on August 12, 2024

Took 3 hours

from csc-308-309-project.

Related Issues (20)

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.