On Mar 23, 9:04 am, Andy Newby <[email protected]> wrote: > Hi, > > I'm trying to add a link on my page (outside of the map), so people can > click on it, and it will then zoom in to the zoom level they set. > > So far I have: > > <a href="javascript: void(0);" > onclick="map.setZoom(jQuery('#article_map_max_zoom_level').val());">Goto > Zoom level</a> > > ..and a function: > > function setZoomLevel(thelevel) { > alert("setting zoom to: " + thelevel); > map.setZoom(thelevel); > } > > The number is being passed in fine (as its showing up on the alert()) ... > BUT I get a JS error in the Error Consol in FF: > > Error: Invalid value for property <zoom>: 6 > Source File:http://maps.gstatic.com/intl/en_gb/mapfiles/api-3/4/6a/main.js > Line: 26 > > I'm guessing its cos I'm "outside" the function where "map" was defined... > even though my code looks like: > > var map; > function initialize() { > ...code that sets the map uyp
Are you sure you aren't redefininig it in here? var map = .... make it local to initialize map = ... uses the global one you defined outside the function. But of course you didn't read and follow the posting guidelines and provide a link so we could be sure... > > } > > Is it possible to do what I'm trying to achieve? (I'm gussing it is, but I > just don't know how ;)) Yes. You need to make your "map" variable global: http://groups.google.com/group/google-maps-js-api-v3/search?group=google-maps-js-api-v3&q=global+map+variable&qt_g=Search+this+group -- Larry > > TIA! > > Andy -- 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.
