Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when using with OpenLayers 4. #32

Open
zion opened this issue Oct 5, 2017 · 3 comments
Open

TypeError when using with OpenLayers 4. #32

zion opened this issue Oct 5, 2017 · 3 comments

Comments

@zion
Copy link

zion commented Oct 5, 2017

Im trying to just follow the basic blueprint of the source files but still getting this error...

Also found this question on stackoverflow

react-openlayers.umd.js:563 Uncaught TypeError: a.V is not a function
    at Hv.k.Nf (react-openlayers.umd.js:563)
    at eh (react-openlayers.umd.js:558)
    at Hv.k.Lf (react-openlayers.umd.js:563)
    at react-openlayers.umd.js:562
    at Array.forEach (<anonymous>)
    at D.k.forEach (react-openlayers.umd.js:460)
    at fh.k.Lf (react-openlayers.umd.js:562)
    at G.k.hp (react-openlayers.umd.js:702)
    at G.<anonymous> (react-openlayers.umd.js:689)

Here is the code...

import React from 'react';
import * as ReactDom from 'react-dom';
import * as ol from 'ol';
import {
  interaction, layer, custom, control, //name spaces
  Interactions, Overlays, Controls,     //group
  Map, Layers, Overlay, Util    //objects
} from "react-openlayers";

// var iconFeature = new ol.Feature(new ol.geom.Point([0, 0]));
// var source = new ol.source.Vector({features: [iconFeature]});
// var marker = new custom.style.MarkerStyle(
//   'https://openlayers.org/en/v4.0.1/examples/data/icon.png'
// );

export default class MapView extends React.Component {
  constructor(props) {
    super(props);
  }

  showPopup = (evt) => {
    this.overlayComp.overlay.setPosition(evt.coordinate);
    var lonlat = ol.proj.transform(evt.coordinate, 'EPSG:3857', 'EPSG:4326');

    this.popupComp.setContents(
      `<p>You clicked here:</p><code> ${lonlat[0]}, ${lonlat[1]}</code>`
    );
    this.popupComp.show();
  }

  render(){
    debugger;
    return (
      <div>
      <Map onClick={this.showPopup}>
        <Layers>
          <layer.Tile source={new ol.source.Stamen({ layer: 'watercolor' })}/>
        </Layers>
        <Overlays>
          <Overlay ref={comp => this.overlayComp = comp}>
            <custom.Popup ref={comp => this.popupComp = comp}>
            </custom.Popup>
          </Overlay>
        </Overlays>
      </Map>
      </div>
    );
  }
}

I did notice that the ol npm project has a specific way of importing the modules, and its different than this repo imports them, but I have tried both ways and am at a loss.

Here is the package.json if it helps, note I am using create-react-app:

{
  "name": "k51-react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "ol": "^4.3.4",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-openlayers": "^0.2.1",
    "react-redux": "^5.0.6",
    "react-router-dom": "^4.2.2"
  },
  "devDependencies": {
    "react-scripts": "1.0.13"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
@jahed
Copy link

jahed commented Nov 6, 2017

The README says it strictly supports OpenLayers 3. I'd guess moving to support OpenLayers 4 will be a major undertaking.

@EvgeneOskin
Copy link

I had the same issue with TypeError.

The README says it supports OpenLayers 3+ – it means 3 and greater 🙂. The supported OpenLayers version was been discussed in #27.

To be precise this library supports OpenLayers 4.0 and works well with this version, but the issue appears with OpenLayers 4.1 and greater.

@omer72
Copy link

omer72 commented Aug 30, 2018

any news regarding this? I get the same error using "ol": "^5.2.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants