Defining a different default scale for a jQuery UI map even with a marker

I tried the Internet to answer this question, but basically, I want the code below to do exactly what it does ....

        $(function() {

            $('#map_canvas').gmap().bind('init', function(ev, map) {
                $('#map_canvas').gmap('addMarker', { 'position': '57.7973333,12.0502107', 'bounds': true }).click(function() {
                    $('#map_canvas').gmap('openInfoWindow', { 'content': '134 Some Street Name, postcode and such' }, this);
                });
            });

        });

    </script>

However, this representation of the map should increase, and I want to be able to control it, but keeping it within. I tried using:

$ ('# map_canvas'). gmap ('option', 'zoom', 7);

below, but it does not matter. How can I control the default zoom of a map before a user clicks or drags something?

Thank!

+5
source share
3 answers

gmap contructor ({zoom: 7}). bounds true addMarker, ( ). false:

$('#map_canvas').gmap({'zoom':7, 'center': '57.7973333,12.0502107'}).bind('init', function(ev, map) {
                $('#map_canvas').gmap('addMarker', { 'position': map.getCenter(), 'bounds': false}).click(function() {
                    $('#map_canvas').gmap('openInfoWindow', { 'content': '134 Some Street Name, postcode and such' }, this);
                });
            });
+8
$(function() {
      $('#map_canvas').gmap().bind('init', function(ev, map) {
           $('#map_canvas').gmap('addMarker', { 'position': '57.7973333,12.0502107', 'bounds': false }).click(function() {
           $('#map_canvas').gmap('openInfoWindow', { 'content': '134 Some Street Name, postcode and such' }, this);
            });
      });
      $('#map_canvas').gmap({'zoom': someNumber});
});

'bounds' false, . .

+2

The easiest way I've found is to go to jquery.ui.map.js and change the default one. It is easy. I set mine at 15.

options: {
center: (google.maps) ? new google.maps.LatLng(0.0, 0.0) : null,
mapTypeId: (google.maps) ? google.maps.MapTypeId.ROADMAP : null,
zoom: 15
},
+1
source

All Articles