89 questions
2
votes
2
answers
149
views
updating Google Map React center using UseState results in NaN's
I have a Map component in my React project, which receives a prop of a current hotel and is supposed to retrieve and present the hotel's location on a Google Map React Map.
This is the code of my ...
2
votes
0
answers
130
views
How can I make my popup appear fully visible on Google map with React?
What I'm doing:
I'm using @react-google-maps/api with React, rendering some markers + popup div.
I'm using OverlayView for the markers on the map.
When I click a pin - I show an info div for that pin....
0
votes
2
answers
317
views
Isolating google-map-react Component to Prevent Global Font Style Overrides in React App
I'm using google-map-react version 2.2.0 in my React application. I've encountered an issue where this component injects a tag into the head of my page, specifically:
<link type="text/css&...
1
vote
1
answer
115
views
Issue with google-map-react package - Unable to set custom center coordinates
This component passes in the address then uses another API to get the latitude and longitude. The latitude and longitude are then passed into the google-map-react API to be converted into a map.
But I'...
1
vote
1
answer
499
views
Custom Maker Icon not Scaling down with scaledSize attribute in @react-google-maps/api library
I have used the @react-google-maps/api library to add a google map and show some custom marker icons on the google map. I have followed the documentation found in here. And added a marker. I have ...
1
vote
0
answers
86
views
React Google Maps API Key Not Translating
I am trying to implement the simple example shown on the google-map-react npm website found here, https://www.npmjs.com/package/google-map-react, but I can't seem to get the API key to translate onto ...
0
votes
0
answers
285
views
Google-Map-React. How to add a map to my react project that has a dynamic center property
Struggling hard with this issue... I need a map on my react app that can change its center dynamically based on data passed in.
Map loads with this current code. Tried to pass lat, lng props into ...
9
votes
2
answers
3k
views
Map marker moves when zooming in and out with google-map-react
I am adding a map with a marker marking a fixed location in my React app, all works fine, but if I zoom out, the marker moves around and goes further to the right of where it should do.
import ...
-1
votes
1
answer
136
views
React Props not populated
Trying to learn React and following this tutorial:https://youtu.be/GDa8kZLNhJ4?t=3547
There you have a App.js component that makes Travel Advisor API call that populates the data object:
import React, ...
0
votes
1
answer
805
views
How can I set another state to pass data to from the initial state in a react class component
can anyone help me out and explain how I can set another state in this component:
export class MapContainer extends Component {
constructor(props) {
super(props);
this.state = {
...
0
votes
1
answer
2k
views
How does a marker in 'google-map-react' get its location based on latitude and longitude from props?
According to https://www.npmjs.com/package/google-map-react, the marker on the map get its location on the map from the longitude and latitude from props.
import React from "react";
import ...
0
votes
2
answers
850
views
React ref callback updating 'this' to update child props not working
I've been hitting the issue mentioned in this thread where, when using the ref callback the refs are updating AFTER componentDidMount.
Apparently this can happen when you pass refs to elements that ...
3
votes
0
answers
208
views
I can't figure out how to make my marker draggable with google-map-react (been trying for a while)
I'm rather new to React & I'm trying to make a map that allows you to drag an infinite number of markers from a sidebar onto the google map.
import GoogleMapReact from 'google-map-react';
import { ...
1
vote
1
answer
2k
views
Use google-map-react fitbounds useRef -> mapRef.current.fitBounds is not a function
I use google-map-react and I want to have the correct zoom and center to the map.
To center the map I use the props center on GoogleMapReact component that I can calculate.
But for the zoom it is more ...
1
vote
2
answers
8k
views
How to draw Polyline with google-map-react?
Everyone I am using google-map-react and not react-google-map. Can you help me drawing a line between two points.
<div className='videoDetails__map'>
<GoogleMapReact
...
0
votes
1
answer
964
views
GoogleMapReact : Next.js: TypeError: Cannot read properties of undefined (reading 'getChildren')
I'm developing a basic nextjs app with the google-map-react component and nextjs. I got the following error every time I try to use the component
TypeError: can't access property "getChildren&...
1
vote
0
answers
27
views
TypeError: Cannot read properties of undefined (reading 'lat') using React version-18 @react-google-maps/api with Rapid Api [duplicate]
I am new to React Google Maps. I am using this library to create a map with several locations and trying fit the boundaries and center it. I am using it to locate restaurants, hotels and all on that ...
10
votes
4
answers
8k
views
google-map-react not loading- Uncaught TypeError: Cannot read properties of undefined (reading 'getChildren')
import React from "react";
import GoogleMapReact from "google-map-react";
const AnyReactComponent = ({ text }) => <div>{text}</div>;
export default function ...
4
votes
2
answers
10k
views
How to use google-map-react with Next.js?
I'm not sure what I'm doing wrong. I'm trying to use google-map-react in my Next.js application. I copied the example on their npm page almost verbatim. Here's the code:
import React from "react&...
0
votes
2
answers
5k
views
How to Get latitude and longitude from Google Maps React onClick
i want to get the coordinates of google map react onclick.
this is my code :
return (
<GoogleMapReact
google={this.props.google}
styles={customizeMap}
style= {ukuran}
...
1
vote
1
answer
530
views
useState not update variable
I'm using google-map-react to display places on google map with auto-suggestion feature, following example here: https://www.freakyjolly.com/google-maps-in-react-example-application. I'm using ...
2
votes
0
answers
337
views
Updating Markers to Google Maps in google-map-react
onGoogleApiLoaded not invoked on locations data change, Is there any way to achieve this?
I tried to use useEffect to load markers but then I have to save map and maps objects in useRef as well as ...
0
votes
1
answer
712
views
Google map react
{!loading ? (
<GoogleMapReact
defaultZoom={isEqual(latLong, USLatLong) ? 4 : 18}
defaultCenter={latLong.lat && latLong.lng ? latLong : USLatLong}
...
1
vote
0
answers
3k
views
google map with search in react js
I'm using google-maps-react library for maps in my react application, and I'm adding search address functionality in my application and facing CORS error.
Error:
Autocomplete.js
import React, { ...
0
votes
1
answer
926
views
How do I point to a location on map with a click event
In React, I'm trying to make an onClick event point a marker on a map to a new location using google-map-react library. My map is showing and I have a button on the map but I'm not sure how to make a ...
1
vote
1
answer
344
views
"google-map-react" npm package -> onClick event -> incorrect 'lat' and 'lng' values
NOT DUPLICATE BECAUSE: Because I am specifically using the "google-map-react" npm package to handle the Google Maps API I don't believe this is a duplicate question. This is more a question ...
0
votes
1
answer
549
views
Google Map React Throwing "refused to apply inline styles error"
CSP Issue:
Our project have strict content security issue i.e. we are using style-src * and cannot add unsafe-inline option here.
I am getting "refused to apply inline styles error" and CSS ...
0
votes
0
answers
606
views
google-map-react - change path colour
I am using google-map-react to render a google map, for a path, using GPS positions. At the moment, I am rendering a path in a single colour.
I would like to change the colour of the line, based on ...
1
vote
1
answer
1k
views
Is there a way to get the coordinates from this draggable marker using google-map-react?
I have made the marker so it is draggable on the map. I am trying to get the coordinates from the marker though so I can save them into my database.
Below is the code , is there a function that I can ...
-2
votes
2
answers
2k
views
How to add custom markers using google maps directions api in react js
Tech Stack - Google Map Directions Api, React JS, etc.
Problem Statement - Using google maps direction Api's i am drawing 3 pins i.e. origin, waypoints and destination. I am able to plot all these of ...
0
votes
1
answer
2k
views
React.js geo position not working in browser on iPhone/Android
I'm trying to get my position on a map and it works fine on my computer in Google Chrome, but when simulating to android/iPhone nothing happens when using for example Custom Location on iPhone ...
2
votes
2
answers
2k
views
google-map-react marker onclick not working
Just to be clear I am using react-google-map https://www.npmjs.com/package/google-map-react
and I followed the documentation clearly and I was able to get it working. here is my code.
import React ...
-2
votes
2
answers
771
views
Disable bubbles on embedded google maps
Any idea how to disable these bubbles on my embedded google map?
I'm embedding this into a react/typescript app with react-google-map
Here is my code :
import React, { FC, useState, useEffect } from '...
-1
votes
1
answer
3k
views
How to display shared link in google map react
I am using react-google-maps and I am able to display location based on lan and lat but I can not find any way to display location using shared link for example
https://goo.gl/maps/YBuwmbwH21yUE19Z9
I ...
3
votes
1
answer
5k
views
How I can make a static map with google-map-react in react?
I have this :
<GoogleMapReact
bootstrapURLKeys={{ key: 'key' }}
defaultCenter={center}
defaultZoom={zoom}
>
<TacoMarker
link={shop.id}
lat={latitude}
lng={...
0
votes
1
answer
769
views
Handle button events inside of google.maps.infoWindow - ReactJS
I'm trying to handle the click event of a button inside a google.maps.infoWindow. I tried to pass the function name to onClick via infoWindow contents but didn't work. So, I moved to getElementById ...
2
votes
0
answers
307
views
'google-map-react' Polyline fails to draw because of poorly managed React state
Being very new to React TS, I'd like some help on managing the sessionEntity variable.
I load data from DB using a function called getEntity(). On dev env. the code below works just fine. On prod ...
0
votes
1
answer
467
views
Is there a way to get Formik to work in Internet Explorer 11 using NextJS
I've been creating a small website using NextJS. I used formik and google-map-react to validate a form and show a basic map.
IE11 is "not cooperating" in using these libraries. I've tried ...
0
votes
1
answer
2k
views
use-supercluster gets empty array
After figuring out how to deal with TypeScript and use-supercluster library I have "made it work" until I got a new problem: I get an empty array whenever I use useSuperCluster() function.
I ...
0
votes
1
answer
593
views
Ternary operator doesn't work as expected
I have a map component where I need to pass default coordinates which will be coming from custom useSwr hook. After fetching the data I pass them to the state and render it if the values or not ...
-2
votes
1
answer
693
views
Setting state using useState results in empty array on first call [duplicate]
I'm using the google-map-react component and I'm attempting to set the coordinates of the position the user clicked on. I have the coordinates, however the first time I click on the map (and the click ...
3
votes
1
answer
8k
views
google-map-react draggable marker - onChildMouseMove not working on mobile
This works beautifully on a computer, but I just tried testing it on mobile, and none of the onChildMouse event handlers are recognized. I've tried finding other event handlers, but onChildMouseXXX is ...
1
vote
1
answer
348
views
value of `google` prop in Map component
Trying to use google-maps-react library.
i imported the following:import {Map,Marker, GoogleApiWrapper} from 'google-maps-react'
one thing is unclear here and i could not find answer on tutorials.
<...
0
votes
1
answer
110
views
How to pass a state's value into props in React class component
I am getting geocode locations into the latt,lngg variables through axios and setState , i want to use this variables inside google-map-react package center How can i pass these state values into ...
1
vote
1
answer
937
views
How to auto-scroll Google Map view in React?
Using the google-map-react package, I've created a MapView component in TypeScript as follows.
export function MapView<I extends Mappable>({ getData }: MapViewProps<I>): JSX.Element {
...
0
votes
0
answers
669
views
How to use Link component inside marker infowindow in nextjs
Hi I am implementing google map in my nextjs app
Here is my map.js component file
import { AsYouType } from 'libphonenumber-js'
import { useState } from 'react';
import {get_location_slug} from '../...
1
vote
0
answers
48
views
Inserting JavaScript giving errors in GoogleMaps
I have two json arrays with which I am trying to produce Markers on a Map.
I'm getting the error:
Attempted import error: 'find' is not exported from './data/geoData.json' (imported as 'geoData').
...
1
vote
1
answer
4k
views
re-render GoogleMapReact
Hi I am creating nextjs Application in which I have used GoogleMapReact from google-map-react library,I want to re-render my GoogleMapReact component according to the new prop
here is my map.js file
...
2
votes
1
answer
3k
views
Google Maps Javascript API throwing InvalidKeyMapError on Production
My code is working fine on localhost, I am using google-map-react package to render map on my react app but when i merged the code in QA or PROD environment the map gets loaded for a second and then ...
2
votes
0
answers
112
views
Can't properly instanciate a Google Map when using pagination
I've been struggling a lot lately with the pagination of a list.
The issue
Each element of that list contains a tiny map and several other information. That list was displaying the map of each row the ...