Comments (6)
FYI I had a similar issue when upgrading to [email protected]. Downgraded back to @5.2.3 and the geocoder now works.
from react-map-gl-geocoder.
Hi @LAYTHJABBAR, I think you may be missing some code. I don't see where your Geocoder
component is being rendered. I can't really help debug without seeing how you're rendering that component. It would help if you provide a Code Sandbox demonstrating the issue.
You can also check out this closed issue #56.
from react-map-gl-geocoder.
Hi @SamSamskies thank you for your response, the Gecoder is rendering on GeocoderTag
import './map.scss';
import React, { useRef } from 'react';
import mapboxgl from 'mapbox-gl';
import ReactMapGL, { Marker, Source, layer } from 'react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';
import 'react-map-gl-geocoder/dist/mapbox-gl-geocoder.css';
import Geocoder from 'react-map-gl-geocoder';
import clsx from 'clsx';
import PropTypes from 'prop-types';
import DropoffPinWithLayer from '../../pages/Routing/Components/Pins/dropoffWithLayer'
const Map = (props) => {
let ZoomCustomer, MarkAllCustomers, GeocoderTag, SearchBarRefrence;
const geocoderContainerRef = React.useRef();
const mapRef = useRef();
if(props.isSearchOutOfMap === true) {
SearchBarRefrence = (<div ref={geocoderContainerRef} />);
}
if (props.geocoder == true) {
GeocoderTag = (
<Geocoder
containerRef={geocoderContainerRef}
mapRef={mapRef}
onViewportChange={props.handleGeocoderViewportChange}
mapboxApiAccessToken={mapboxgl.accessToken}
position={props.position}
onResult={props.handleOnResult}
ReverseGeoCode={true}
onClear={props.handleOnClear}
/>
);
}
if (props.customerToZoom == true) {
ZoomCustomer = (
<Marker latitude={props.customerToMark.lat} longitude={props.customerToMark.lon} >
{props.marker}
</Marker>
);
}
if (props.customerToZoom == true && props.itsDraggable === true) {
ZoomCustomer = (
<DropoffPinWithLayer
location={ props.customerToMark }
onDragEnd={props.handleOnDragEnd}
radius={props.radius}
/>
);
}
if (props.markCustomers == true) {
let customers = props.customers;
MarkAllCustomers = customers.map((customer) => {
const { lon, lat, uuid } = customer;
if (props.customerArr) {
return (
<Marker key={uuid} longitude={lon} latitude={lat}>
<i
type="button"
className={clsx(props.styles.pin, { [props.styles.selected]: props.customerArr.includes(customer) })}
onMouseDown={() => props.mouseDown(customer)}
/>
</Marker>
);
} else if (props.selcustomers) {
return (
<Marker key={uuid} longitude={lon} latitude={lat}>
<i
type="button"
className={clsx(props.styles.pin, { [props.styles.selected]: customer.name === props.selCustomer })}
onMouseDown={() => props.mouseDown(customer.name)}
/>
</Marker>
);
}
});
}
return (
<div>
{SearchBarRefrence}
<ReactMapGL
{...props.viewport}
ref={mapRef}
width={props.width}
onClick={(event) => {
props.handleOnClickEnd(event)
}}
height={props.height}
onViewportChange={props.handleViewportChange}
mapboxApiAccessToken={mapboxgl.accessToken}
mapStyle="mapbox://styles/mapbox/outdoors-v11"
>
{ZoomCustomer}
{MarkAllCustomers}
{GeocoderTag}
</ReactMapGL>
</div>
);
};
Map.propTypes = {
width: PropTypes.string,
onViewportChange: PropTypes.func,
mapboxApiAccessToken: PropTypes.string,
onResult: PropTypes.func,
onClear: PropTypes.func,
position: PropTypes.string,
itsDraggable: PropTypes.bool,
handleOnDragEnd: PropTypes.func,
radius: PropTypes.number,
height: PropTypes.string,
handleOnClickEnd: PropTypes.func,
};
Map.defaultProps = {
width: '100px',
handleOnClickEnd: (event) => {console.log(event)},
handleOnDragEnd: () => {},
onViewportChange: () => {},
onResult: () => {},
onClear: () => {},
mapboxApiAccessToken: '',
position: 'top-left',
itsDraggable: false,
radius: 0,
height: "220px"
};
export default Map;
from react-map-gl-geocoder.
It looks like you're conditionally rendering the geocoder container. The problem could be that you're rendering the Geocoder
and not rendering SearchBarRefrence
which would probably cause the errors that you're having. Try removing the containerRef
prop to verify.
Another issue that I see is that there is no prop called ReverseGeoCode
. I think you want reverseGeocode
.
Also, make sure all of the Geocoder
props that are objects or functions are memoized. You're passing in a bunch of the props from a parent component, and I'm not sure if you're memoizing the values or not.
from react-map-gl-geocoder.
@Matt-Vance exactly what happened to me. Downgrading to react-map-gl @5.2.3 solved it.
from react-map-gl-geocoder.
Thanks @Matt-Vance the issue got solved by downgrading react-map-gl to @5.2.3
from react-map-gl-geocoder.
Related Issues (20)
- GeoCoder Marker's Styling Not Working HOT 2
- Search Results Not closing, and marker not dropping HOT 9
- Geocoder doesn't appear in Next.js app HOT 1
- Console error passing object to marker prop
- Suggestions are displayed after setting a default input HOT 3
- External geocoder HOT 1
- React 17? HOT 1
- how to active draggable after search HOT 1
- mapbox-gl neccessary dependency? HOT 1
- How to get the current value? HOT 3
- Typescript import issue HOT 1
- Supporting stand-alone Geocoder without map ? HOT 1
- react-map-gl 7 support HOT 7
- Multiple input options in react app HOT 1
- export 'FlyToInterpolator' (imported as 'r') was not found in 'react-map-gl' HOT 2
- Request to upgrade transitive dependency `http-cache-semantics` in `react-map-gl-geocoder` HOT 1
- Menu stays open HOT 2
- Upon passing Marker="true" into geocoder, no point appears HOT 4
- Can Not Use react.map.gl.gecoder with Typescript HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-map-gl-geocoder.