Custom Zoom Control UI
See original GitHub issueHello, this is the first time I am opening issue in this project. I have a question regarding adding custom control. Here is my environment:
- “react-google-maps”: “^9.4.5”
- “react”: “^16.3.2”
- “react-dom”: “^16.3.2”
Upon some googling and stackoverflow searching. I have found some good references: For example:
- https://jsfiddle.net/maunovaha/jptLfhc8/
- https://developers.google.com/maps/documentation/javascript/examples/control-custom
However, I don’t think the .controls
are in the google.maps
object.
Following is my code:
class MapComponent extends Component {
constructor(props){
super(props);
this.mapComponentRef = React.createRef();
}
render(){
return (
<GoogleMap
ref={this.mapComponentRef}
/>);
}
}
I can confirm that I can access the ref of the map. For example, I use
this.mapComponentRef.current.fitBounds(this.bounds);
to update the bounds of the map and it works.
However, when I try to do this.mapComponentRef.current.controls[google.maps.ControlPosition.TOP_CENTER].push(centerControlDiv)
, it gives me errors that the controls
is undefined.
Does anyone has pointer on how to get access the controls
so I can push my custom component to control the zoom level of the map?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Zoom Controls - Dribbble
Discover 1 Zoom Controls design on Dribbble. ... animation app behance case study controls customization dashboard interaction interface mobile motion ui.
Read more >Custom UI Feature - Zoom App Marketplace
Custom UI Feature · Contents · Initialize the SDK · Create Customized UI Service and SetEvent · Create Video Container, Video Element(s) and...
Read more >Zoom Controls | UI Controls | Common Settings
Zoom Control Panel is an HTML object with three buttons: Zoom All (100%, or 1x Zoom), Zoom In and Zoom Out. To create...
Read more >Class of the UI Control ZOOM in HERE MAPS - Stack Overflow
The Maps API supports changing the position of the UI controls. In the following example, all map controls are moved to the top-left...
Read more >Controls | Maps JavaScript API - Google Developers
The following example sets the map to hide the Zoom control and display the Scale control. Note that we do not explicitly disable...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For anyone who is looking into this issue. I have posted my solution in https://github.com/tomchentw/react-google-maps/issues/82#issuecomment-412579391 .
I will close this PR now. Thanks so much for the help.
you just need to add current to ref
<CustomControl mapHolderRef={this.mapComponentRef.current} controlPosition={window.google.maps.ControlPosition.TOP_LEFT} > <div onClick={() => this.mapComponentRef.current.map.setZoom(8)}>testing component</div> </CustomControl>