
Pictured above are three tabs made with jquery. The third (which is opened in the picture) contains an embedded Google Map. The empty red rectangle is the location where the map should appear. The above error is only present in Safari, I couldn't replicate it in any other browser.
The map is wrapped inside a div called
- <h3 id="pasek3"><a href="#"></a></h3> // third panel
<div id="content_wrap">
<div id="podPaskiem3"> // under the panel
<p id="lewo1"> // left half
CONTACT/ADRESS DETAILS
</p>
<p id="prawo2"> // right half
<div id="mapCanvas"></div>
</p>
</p>
</div>
</div>
<!--content_wrap--></div >
These are that divs properties
- #mapCanvas {
- border: 0;
- width: 500px;
- height: 350px;
- margin: 0 auto;
- }
Here is the script responsible for displaying and centering the map once the third map is opened:
- <script>
- var map = null;
- var latlng = new google.maps.LatLng(52.2729782, 20.9861867);
- function initializeMap() {
- var myOptions = {
- zoom: 15,
- center: latlng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- };
- return new google.maps.Map($('#mapCanvas')[0], myOptions);
- }
- // Function for adding a marker to the page.
- function addMarker(location) {
- marker = new google.maps.Marker({
- position: location,
- map: map
- });
- }
- // Testing the addMarker function
- function TestMarker() {
- CentralPark = new google.maps.LatLng(52.2729782, 20.9861867);
- addMarker(CentralPark);
- }
- $(document).ready(function() {
- $("#accordion").accordion();
-
- $("#accordion").bind('accordionchange', function(event, ui) {
- if (ui.newContent.attr('id') == 'content_wrap' && !map)
- {
- map = initializeMap();
- TestMarker();
- }
- });
- });
- </script>
In case you have stumbled upon this thread looking for a solution to an issue with Google Map displaying/centering, here is what worked for me http://www.essentialwebconcepts.com/blog/2011/03/22/fixing-google-maps-rendering-problem-in-jquery-accordion/the above does not adrress my question, it's an answer to different question