Saturday 6 May 2017

Using leaflet within create-react-app in node.js

I am a novice programmer trying to incorporate leaflet through create-react-app for a project. With very little background in node.js I have run into several issues. I believe I have installed leaflet properly through node.js and have done the following to implement my code in the "app.js" file:

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
var axios = require("axios")
var leaflet = require("leaflet")
var map = leaflet.map('map');
map.setView([47.63, -122.32], 11);
class App extends Component {
  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <div id = 'map'></div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
      </div>
    );
  }
}

export default App;

The output to the local host after this is run is a blank page. Considering I have little experience in this domain, I was wondering if I was headed down the right track, or if anyone has suggestions for a fix.

Thank you



via Taylor Rohrich

No comments:

Post a Comment