react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

Popup doesn't fire

Open 129emma opened this issue 7 years ago • 1 comments

I basically using Typescript to copy and paste from the example to show the popup info when the icon is clicked. However, it doesn't work at all. I changed to Popup Api documentation and write the exactly code, and I got the error message as follow

Uncaught Error: viewport-mercator-project: assertion failed. at assert (assert.js:3) at worldToPixels (web-mercator-utils.js:187) at WebMercatorViewport.project (viewport.js:69)

As long as I remove Popup component, the application works well. React version: 16.6.3 React map gl version: 4.0.9 Any ideas? Thanks in advance!

import * as React from "react";
import ReactMapGL, {Marker, ViewState, Popup} from 'react-map-gl';


interface State {
    showInfo: boolean,
    viewPort:{
        latitude: number,
        longitude: number,
        zoom: number
    }
}


export default class GeoDetails extends React.Component<{}, State> {
    
    public static style = require('./GeoDetails.module.scss');
    
    public constructor({}){
        super({});
        this.state = {
            viewPort:{
                latitude: -40.848461,
                longitude: 188.763336,
                zoom: 8,
            },
            showInfo: false
        }
    }
    
  
    
    public render(): React.ReactNode {
        return (
            <React.Fragment>
              
                {this.renderMap()}
               
            </React.Fragment>
        )
    }
    
    private renderMap = () => {
        
        const mapStyle = "mapbox://styles/mapbox/streets-v9";
        const accessToken= "pk.eyJ1IjoiMTI5ZW1tYSIsImEiOiJjanJiZ2VycHYxMnJyNDRudnd4YjA1YzZ6In0.uFQh4pZFu-Qp0KlzBBnrJg"
    
        return (
            <ReactMapGL {...this.state.viewPort}
                        width={400}
                        height={400}
                        mapboxApiAccessToken={accessToken}
                        mapStyle={mapStyle}
                        onViewportChange={this.onViewportChange}
            >
                
                <Popup latitude={188.7777943} longitude={-40.868139} closeButton={true} closeOnClick={false} anchor="top">
                    <div>You are here</div>
                </Popup>
            </ReactMapGL>
        )
    };
    
    private onViewportChange = (viewState: ViewState) => {
       this.setState({
           viewPort: viewState
       })
    };
    

    
  
    

    

    
}

129emma avatar Jan 29 '19 00:01 129emma

The problem solved when I modify the latitude and longitude. solution: https://github.com/uber/react-map-gl/issues/675#issuecomment-450507576

129emma avatar Jan 29 '19 00:01 129emma