I just tried that, you need to parse the zoom value to an integer:

 zom= parseInt(document.getElementById("zm").value);

The following works, but if you remove the parseInt call the map doesn't
even load:

  function initialize() {
    var zoom = parseInt(document.getElementById("zoom").value);
    var myOptions = {
      zoom: zoom,
      center: new google.maps.LatLng(-33, 151),
      disableDefaultUI: true,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"),
                                  myOptions);
  }

Cheers,
Miguel

On Wed, May 26, 2010 at 18:29, walterg <[email protected]> wrote:

> Is it possible to use a variable for the zoom option when intializing
> the map?
> This does not work though the zom variable contains a number as the
> alert(zom) attests.
> var geocoder;
>  var map;
>  var zom;
>  function initialize() {
>  zom= document.getElementById("zm").value;
>   geocoder = new google.maps.Geocoder();
>   var latlng = new google.maps.LatLng(43.564, 1.321);
>  // alert(zom)
>    var myOptions = {
>      zoom:  zom
>       center: latlng,
>      mapTypeId: google.maps.MapTypeId.ROADMAP
>    }
>    map = new google.maps.Map(document.getElementById("map_canvas"),
> myOptions);
>        }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-maps-js-api-v3%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to