Set a default zoom for google maps

Asked

Viewed 620 times

3

Good morning,

I have a question about google maps. I am with a company location map, however I would like to put a default zoom, for example, zoom 3, that when opening the page, the zoom will 3 automatically.

    <iframe width="940" height="368" frameborder="0" scrolling="no"
            marginheight="0" marginwidth="0"
            src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3600.4437971068405!2d-54.5645733!3d-25.52359!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x94f690f5e6033f2f%3A0x3b3245f53467c160!2sZeni+Motors!5e0!3m2!1spt-BR!2sbr!4v1442932960309"></iframe>

1 answer

2


Follows script with mouse scrolling options, zoom, among other options:

 <script type="text/javascript" src="https://maps.google.com/maps/api/js"></script>
 <script>
                    //Chamar mapa 
                    function initialize() {
                        // Create a map object, and include the MapTypeId to add
                        // to the map type control.
                        var latlng = new google.maps.LatLng(-27.230399, -52.028978);
                        var myOptions = {
                            zoom: 15,
                            center: latlng, //localizacao do ponteiro, definida acima na var latlng.
                            scrollwheel: false, //desativar scroll
                            mapTypeControl: false, //desativa opcao de escolha de mapa
                            panControl: false, //desativa movimentacao no mapa
                            //zoomControl: false, //desativa zomm no mapa
                        };
                        var map = new google.maps.Map(document.getElementById("mapa_localiza"), //mapa_localiza é o id o quale usado na div a baixo para chamar o mapa.
                            myOptions);
                        //define o ponteiro 
                        var image = '<?php print base_url(); ?>web-files/site/img/marker.png';
                        var beachMarker = new google.maps.Marker({
                            position: latlng,
                            map: map,
                            icon: image
                        });
                    }
                    google.maps.event.addDomListener(window, 'load', initialize);
                </script>

                <div id="mapa_contato">
                    <div id="mapa_localiza" style="height: 26em; width: 100%; float: left;"></div><!--CHAMA O MAPA, define altura do mesmo-->
                </div>

In the Zoom field, you can set the initial zoom. In the var image you can set the map cursor.

  • Thank you, include in the project and worked perfectly!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.