-1

I need some help in controlling the zoom level in a google map. I'm using the jquery-ui-map plugin but everything I searched for and found doesn't seem to work. Here is what i came up with in following some examples they have.

<script type="text/javascript">
  $(function() {
    // Also works with: var yourStartLatLng = '59.3426606750, 18.0736160278';
    var yourStartLatLng = new google.maps.LatLng();
    $('#map_canvas').gmap('addMarker', {'position': '32.311042,-106.781458', 'bounds': true});
    $('#map_canvas').gmap('zoom', 15);
  });
</script>

Thanks for the help.

Anto Jurković
  • 11,188
  • 2
  • 29
  • 42
Automator21
  • 647
  • 2
  • 7
  • 11

1 Answers1

0

You have to setup map and then add marker. For example:

$(document).ready(function(){
    var lat = 32.311042; 
    var lng = -106.781458; 
    var center = new google.maps.LatLng(lat, lng); 

    var mapOpt = {
        center: center, 
        zoom: 15,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    $('#map_canvas').gmap(mapOpt);

    $('#map_canvas').gmap('addMarker', {'position': '32.311042,-106.781458', 'bounds': false});
});

And changing zoom parameter you will get different level of details.

Update: example at jsbin

Anto Jurković
  • 11,188
  • 2
  • 29
  • 42
  • How do I get my map to refresh once it loads using the code above? The map only appears partial until I hit the refresh button. Thanks. – Automator21 Jan 29 '14 at 17:46
  • @Automator21 I updated the answer with example at jsbin. Check it out in case you missed something. BTW, which browser do you use? – Anto Jurković Jan 29 '14 at 18:18
  • Sorry I was vague in my question, i'm using jQuery Mobile and testing my web app on iOS safari. The map only renders partial but if I refresh the map will render completely. – Automator21 Jan 29 '14 at 18:36
  • I have no such environment to check it. With Safari it works like with Chrome or FF on Windows sysem. I suggest to open new question, describe environment and provide some code. I don't know if there is some similar question. – Anto Jurković Jan 29 '14 at 19:11