Comments (10)
I actually just ran into a similar situation. I'm leaving this note for someone else in the future. After a good amount of hair pulling I found that if you're passing "options" and the map is flickering like crazy, you should instead pass the values as "defaultOptions".
from react-google-maps.
Meanwhile I figured out the source of my problem. I define custom position of the map controls and pass the map options as props:
getDefaultProps: function(){
return {
mapOptions : {
mapTypeId: google.maps.MapTypeId.SATELLITE,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_RIGHT
},
panControl: true,
panControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE,
position: google.maps.ControlPosition.RIGHT_TOP
},
scaleControl: true,
scaleControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
streetViewControl: false,
scrollwheel: false
}
}
},
/*...*/
render:
/*...*/
<GoogleMaps {...this.props.mapOptions}
/*...*/ >
{polylines}
</GoogleMaps>
By some reason, React thinks the props has changed (while they aren't) and redraws the map controls.
from react-google-maps.
More exactly, any customisation of the map controls in props leads to controls flickering when the children are updated. E.g.
<GoogleMaps mapTypeControlOptions = {{
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_RIGHT
}}>
...
Do you have any suggestion how to solve that?
from react-google-maps.
Hi @ksavenkov , I took a day to rewrite the module from scratch on #88 . Not sure if it will help but it will be great if you could take a look at it. Thanks!
from react-google-maps.
@tomchentw, great improvement! Yes, now the problem resolved. However, it's a bit tedious to write "default" prefix for all 10+ map options - is that possible to make defaultOptions={...} prop work for GoogleMap component much like it works for markers etc. ?
from react-google-maps.
defaultOptions
and options
are supported for markers as well. It's the same semantic for stock Google Maps JavaScript API v3
from react-google-maps.
I mean, it seems they aren't supported for GoogleMap component.
from react-google-maps.
I saw there's a setOptions
on Marker class in v3.21
from react-google-maps.
My bad - I wrapped props for GoogleMap in options={...}
and forgot to remove default- prefixes. Now everything works just fine - I create custom controls and they aren't rerendered.
from react-google-maps.
map is flickering while typing input and searchbox
from react-google-maps.
Related Issues (20)
- how to add button re center on map HOT 1
- Problems while implementing Content Security Policy HOT 1
- Polygon not being drawn on the map HOT 1
- CWE-601 Security Vulnerability found in one of the transitive dependencies HOT 1
- Legacy context API has been detected within a strict-mode tree. HOT 1
- AutoComplete Default Value
- Check this use 'window'
- Error when installing HOT 3
- Could not resolve dependency: npm ERR! peer react@"^16 || ^17" from [email protected]
- Problem in Installation HOT 2
- I can not push custom control button to the map
- More than 700 re renderings HOT 1
- Is there any benefits to using MarkerClusterer, rather than simply using Markers?
- Best Way To Style Marker Labels?
- KMlLayer 2d, 3d kmz file or kml file highlighted layer not showing
- f.setPosition is not a function
- How can I get the DOM element for Marker?
- disable map zoom when DirectionsRenderer redraws the path
- Upgrade jQuery dependency inside scriptjs package. HOT 1
- Update needed?
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-google-maps.