1

Okay, I'm feeling fairly dense for not being able to figure the last part of this out, so hopefully somebody can show me the last piece of the puzzle. I have one example of a polygon that always needs to be visible and another example that uses map.fitBounds() with the same area defined so it IS always visible. The last step is displaying that polygon overlaid on the map.fitBounds() map.

    var southWest = new google.maps.LatLng(41.49623534616764, -88.209228515625);
    var northEast = new google.maps.LatLng(42.64810165693524, -86.4019775390625);
    var bounds = new google.maps.LatLngBounds(southWest,northEast);
    map.fitBounds(bounds); 

Essentially, the code above needs to either replace or supplement the center functionality, which is what I don't get:

var mapOptions = {
    zoom: 8,
    zoomControl: true,
    scaleControl: true,
    scrollwheel: false,
    disableDoubleClickZoom: false,
    mapTypeControl: true,
    navigationControl: true,
    streetViewControl: true,
    center: new google.maps.LatLng(41.845644,-87.766685),
    mapTypeId: google.maps.MapTypeId.ROADMAP
};
var serviceAreaSealMaster;

I recreated it on codepen: http://codepen.io/Realto619/pen/EbmJi

Thanks in advance!

Realto619
  • 301
  • 3
  • 13
  • 2
    possible duplicate of [How to get the center of a polygon in google maps v3?](http://stackoverflow.com/questions/3081021/how-to-get-the-center-of-a-polygon-in-google-maps-v3). Get the bounds of your polygon, call map.fitBounds with that bounds. – geocodezip May 02 '14 at 22:12
  • @geocodezip Thanks, I pretty much figured that was the case, but I couldn't figure out where to add it to make it work. Fortunately a fresh set of eyes helped me solve yesterday's density issue. I forked my original codepen with the solution if anyone is interested: http://codepen.io/Realto619/pen/Dirfn – Realto619 May 04 '14 at 03:09

1 Answers1

0

As I mentioned in my comment, geocodezip's confirmation that I was on the right track and a fresh set of eyes solved the problem and I posted the solution in a forked codepen http://codepen.io/Realto619/pen/Dirfn

(Nevermind, the following is no longer an issue:) PS: In case anyone looks at that and wonders why it doesn't appear to be resizing correctly in a few instances, I'm pretty sure that its the boundary that I defined not being as accurate as it needs to be. I'll be fixing that next, but I didn't want to confuse anyone that might see it before then...

Realto619
  • 301
  • 3
  • 13