Coder Social home page Coder Social logo

Comments (6)

SamSamskies avatar SamSamskies commented on June 12, 2024 1

Thanks for the info. I've never used the reuseMaps prop before. I'll need to look into that.

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on June 12, 2024

Hi @matinfo, what version are you using? Are there any errors in the dev console when this happens?

from react-map-gl-geocoder.

matinfo avatar matinfo commented on June 12, 2024

@SamSamskies the version used are:
"mapbox-gl": "^1.3.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"react-map-gl": "^5.0.10",
"react-map-gl-geocoder": "^2.0.11",
"react-router-dom": "^5.0.1",
"viewport-mercator-project": "^6.2.0",

and not error in the console.

My render look like this:

render() {
    const { viewport, settings, mapMarkers } = this.state;

    return (
      <MapGL
        {...viewport}
        {...settings}
        width="100%"
        height="100%"
        mapStyle="mapbox://styles/XXXXXXXXX/cjy4nlft63s0w1bqlto3pfar0"
        mapboxApiAccessToken={MAPBOX_TOKEN}
        onViewportChange={(viewport, interaction) => this._onViewportChange(viewport, interaction)}
        reuseMaps={true}
        ref={this.mapRef}
      >
        {mapMarkers.map(this._renderMarker)}
        {this._renderPopup()}

        <div className="fullscreen" style={fullscreenControlStyle}>
          <FullscreenControl />
        </div>
        <div className="nav" style={navStyle}>
          <NavigationControl
            showCompass={false}
            onViewportChange={(viewport, interaction) => this._onViewportChange(viewport, interaction)}
          />
        </div>
        <Geocoder
          mapRef={this.mapRef}
          onViewportChange={this._handleGeocoderViewportChange}
          mapboxApiAccessToken={MAPBOX_TOKEN}
          position="top-left"
          trackProximity={true}
          clearAndBlurOnEsc={true}
          placeholder="Search location"
          countries="ch"
        />
      </MapGL>
    );

I found the cause of the issue, if I change to reuseMaps={false} the search field are not duplicated!

from react-map-gl-geocoder.

mohridwanhdp avatar mohridwanhdp commented on June 12, 2024

I wrap my ReactMapGl with Deck.gl, I use the suggestion to use reuseMap but still rendered minima three times,

and after the viewport changed, it become so many search field

from react-map-gl-geocoder.

SamSamskies avatar SamSamskies commented on June 12, 2024

Hi @mohridwanhdp, could you provide an example in Code Sandbox that demonstrates your issue?

from react-map-gl-geocoder.

mohridwanhdp avatar mohridwanhdp commented on June 12, 2024

Hi @mohridwanhdp, could you provide an example in Code Sandbox that demonstrates your issue?

I'm sorry it's my mistake here cause not use the right ref

Before, I use this in my ReactMapGL
<ReactMapGL
mapStyle={mapStyle}
mapboxApiAccessToken={MAPBOX_TOKEN}
preserveDrawingBuffer={true}
ref={(reactMap) => (this.reactMap = reactMap)}
reuseMaps={false}
onLoad={(e) => {
this._onMapLoaded();
}}
>

Then i change the ref like this :
ref={this.reactMap}

And It's become normal

from react-map-gl-geocoder.

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.