Can't get Google Maps API to zoom out after loading GeoRSS file

Go To StackoverFlow.com

0

I am attempting to build an application that imports GeoRSS files into Google Maps, however I am seeing strange behavior where I can't get the map to zoom out after I import the file. It is stuck zoomed right into the first pin that is imported by the file.

See below code for example:

<script type="text/javascript">
  function initialize() {
    var myOptions = {
    zoom:0,
    mapTypeId: google.maps.MapTypeId.SATELLITE 
  };

var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
var georssLayer = new google.maps.KmlLayer('https://twitter.com/statuses/user_timeline/findingnewo.rss');
georssLayer.setMap(map);
map.setZoom(0);
  }

</script>

Anyone seen similar behavior?

2012-04-05 01:17
by Owen


0

Here's your answer:

https://developers.google.com/maps/documentation/javascript/layers#KMLLayers

When you add a KML layer, the default behaviour is to zoom and position the map to fit the layer contents. You can supply an option to prevent this from happening.

Options:

https://developers.google.com/maps/documentation/javascript/reference#KmlLayerOptions

Example:

var options = { preserveViewport: true },
    georssLayer = new google.maps.KmlLayer('https://twitter.com/statuses/user_timeline/findingnewo.rss', options);
2012-04-05 01:23
by ScottE
Worked PERFECT! Thank you so much. I'm reading through the options page now - Owen 2012-04-05 01:55
Ads