Hi, The marker on the map of my website is located in the top left corner. I want the marker to be in the centre of map. You can see it here (bottom of the page): www.xeryon.com When I reload the page, the marker is centred. This issue started from the moment I added the 'loadpage' function and timeout. How can I solve it so that the marker is always centred?
<head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link href="images/logo_x_transparent.ico" rel="shortcut icon" type= "image/vnd.microsoft.icon" /> <link href="images/logo_x_transparent.ico" rel="icon" type= "image/vnd.microsoft.icon" /> <link href="http://fonts.googleapis.com/css?family=Raleway" rel="stylesheet" type="text/css" /> <link href="http://fonts.googleapis.com/css?family=Raleway:200" rel= "stylesheet" type="text/css" /> <link href="http://fonts.googleapis.com/css?family=Raleway:300" rel= "stylesheet" type="text/css" /> <link href="http://fonts.googleapis.com/css?family=Raleway:500" rel= "stylesheet" type="text/css" /> <link href="http://fonts.googleapis.com/css?family=Raleway:600" rel= "stylesheet" type="text/css" /> <meta content="width=device-width, initial-scale = 1.0, user-scalable = no" name="viewport"> <title>XERYON - Experts in Piezo and Precision technology.</title> <link href="products/default.css" media="screen" rel="stylesheet" type= "text/css"> <link href="stylesheet/normaliz.css" media="screen" rel="stylesheet" type= "text/css"> <link href="stylesheet/960.css" media="screen" rel="stylesheet" type= "text/css"> <link href="stylesheet/prettyPhoto.css" rel="stylesheet" type="text/css"> <link href="stylesheet/font-awesome.min.css" rel="stylesheet" type= "text/css"> <link href= "http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet"> <script src="js/jquery.js" type="text/javascript"></script> <script src="js/jquery.easing.js" type="text/javascript"></script> <script src="js/jquery.prettyPhoto.js" type="text/javascript"></script> <script src="js/jquery.sticky.js" type="text/javascript"></script> <script src="js/jquery.stellar.js" type="text/javascript"></script><!--moves the background position--> <script src="js/jquery.waypoints.js" type="text/javascript"></script> <script src="js/jquery.isotope.js" type="text/javascript"></script> <script src="js/custom.js" type="text/javascript"></script> <script type="text/javascript"> $(function(){ jQuery("a[data-gal^='prettyPhoto']").prettyPhoto({ social_tools: '' }); }); </script> <script src= "https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" ></script> <script type="text/javascript"> var myVar; function loadpage() { myVar = setTimeout(showPage, 500); } function showPage() { document.getElementById("loader").style.display = "none"; document.getElementById("myDiv").style.display = "block"; google.maps.event.trigger(map, 'resize') } </script> <script type="text/javascript"> function initMap(){ myVar = setTimeout(loadmap, 1000); } function loadmap(){ var myOptions = {zoom:10,scrollwheel:false,styles: [{"featureType":"water", "elementType":"geometry.fill","stylers":[{"color":"#d3d3d3"}]},{ "featureType":"transit","stylers":[{"color":"#808080"},{"visibility":"off" }]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers" :[{"visibility":"on"},{"color":"#b3b3b3"}]},{"featureType":"road.highway", "elementType":"geometry.fill","stylers":[{"color":"#ffffff"}]},{ "featureType":"road.local","elementType":"geometry.fill","stylers":[{ "visibility":"on"},{"color":"#ffffff"},{"weight":1.8}]},{"featureType": "road.local","elementType":"geometry.stroke","stylers":[{"color":"#d7d7d7" }]},{"featureType":"poi","elementType":"geometry.fill","stylers":[{ "visibility":"on"},{"color":"#ebebeb"}]},{"featureType":"administrative", "elementType":"geometry","stylers":[{"color":"#a7a7a7"}]},{"featureType": "road.arterial","elementType":"geometry.fill","stylers":[{"color":"#ffffff" }]},{"featureType":"road.arterial","elementType":"geometry.fill","stylers" :[{"color":"#ffffff"}]},{"featureType":"landscape","elementType": "geometry.fill","stylers":[{"visibility":"on"},{"color":"#efefef"}]},{ "featureType":"road","elementType":"labels.text.fill","stylers":[{"color": "#696969"}]},{"featureType":"administrative","elementType": "labels.text.fill","stylers":[{"visibility":"on"},{"color":"#737373"}]},{ "featureType":"poi","elementType":"labels.icon","stylers":[{"visibility": "off"}]},{"featureType":"poi","elementType":"labels","stylers":[{ "visibility":"off"}]},{"featureType":"road.arterial","elementType": "geometry.stroke","stylers":[{"color":"#d6d6d6"}]},{"featureType":"road", "elementType":"labels.icon","stylers":[{"visibility":"off"}]},{},{ "featureType":"poi","elementType":"geometry.fill","stylers":[{"color": "#dadada"}]}], center:new google.maps.LatLng(50.84934800000001,4.735665199999971),mapTypeId : google.maps.MapTypeId.ROADMAP};map = new google.maps.Map(document. getElementById('gmap_canvas'), myOptions);marker = new google.maps.Marker({ map: map,position: new google.maps.LatLng(50.84934800000001, 4.735665199999971),icon:'http://www.googlemapsmarkers.com/v1/8BFA02/'});infowindow = new google.maps.InfoWindow({content:'<strong>Xeryon</strong><br>Interleuvenlaan 62, Leuven<br>'});google.maps.event.addListener(marker, 'click', function(){ infowindow.open(map,marker);});infowindow.open(map,marker);}google.maps. event.addDomListener(window, 'load', init_map); </script> <body onload="loadpage()" style="margin: 0;"> <div class="grid_12" id="loader"> </div> <div id="myDiv" class="animate-bottom"> ... <!-- Google maps start --> <script async="" defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCVV-HH7g0RyA0hsXUkXWFZ1R09FOvBwiU&callback=initMap"> </script> <div style=" height: 350px; width: 100%;"> <div id="gmap_canvas" style="height: 350px; width: 100%;"> </div> <style> #gmap_canvas img { max-width: none!important; background: none!important; } </style> </div> <!-- Google maps end--> ... </div> </body> </html> -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-maps-js-api-v3. For more options, visit https://groups.google.com/d/optout.
