in Education by
I have a google map set with the Javascript API V3. It's displayed in a div with a dynamic width, as a content pane slides up when we click on a marker. Everything works fine, but one thing: When the pane slides up, the width of the map is changed, and so the center is displaced to the right (the pane is on the left). It is really inconvienient especially for small resolutions, where you can't even see the center after the pane is open. I've tried the 'resize' trigger, but it doesn't seem to work... Any ideas ? Thanks a lot ! JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Calling resize by it self will not acheive what you need. What you need to do is first (before a resize occurs) get the current center of the map var currCenter = map.getCenter(); Then you need to do something like the following, after your div is resized. google.maps.event.trigger(map, 'resize'); map.setCenter(currCenter); Should do the trick UPDATE 2018-05-22 With a new renderer release in version 3.32 of Maps JavaScript API the resize event is no longer a part of Map class. The documentation states When the map is resized, the map center is fixed The full-screen control now preserves center. There is no longer any need to trigger the resize event manually. source: https://developers.google.com/maps/documentation/javascript/new-renderer google.maps.event.trigger(map, "resize"); doesn't have any effect starting from version 3.32

Related questions

0 votes
    I have a google map set with the Javascript API V3. It's displayed in a div with a dynamic width ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    What I'm trying to do should be something extremly simple but still I cannot seem to get it done ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    Maps are great to get things done easily, but they are memory hogs and suffer from caching issues. And ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Maps are great to get things done easily, but they are memory hogs and suffer from caching issues. And ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I don't need so many pins , they are crowding the area. I used the output of kml parser to draw ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I am following up with the Wirecloud User Guide available here https://wirecloud.readthedocs.io/en/latest/ ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I am using this for slide up layout in my map fragment but my app just crashing again and again ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am using this for slide up layout in my map fragment but my app just crashing again and again ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I have a google map and is not displayed properly. To see what I'm talking about check this LINK ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
0 votes
    I have source and destination latitude and longitude values, and wish to display a Google map showing the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 23, 2022 in Education by JackTerrance
0 votes
    I'm trying to incorporate Google Maps into my Access form so that for every record a map of its ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    What is Distribution and map overlay in Google Analytics?...
asked Oct 3, 2020 in Technology by JackTerrance
0 votes
    What is the actual difference between Google Compute Engine, App Engine and Container Engine in Google Cloud Compute ... three engines? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    What is Google Container Engine?...
asked Oct 2, 2021 in Technology by JackTerrance
0 votes
    My RPM package name was (for example) testing-1.0.0.rpm, however when i did an artifactoryPublish ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
...