I've made a google map mashup displaying polygons created from an xml
file. I'm wanting the map to zoom into an individual polygon after
it's name is selected from a drop down menu. I'm trying to use a
polygon's shape or center to do this and just can't figure out the
proper syntax do it. See snippets of the script below or visit
(
http://www.geology.ar.gov/test/quad24k_map.htm). Thanks!
var quadArray = [];
var q = 0;
function createPolygon(pts, html, latlng, color, name) {
var quads = new google.maps.Polygon(
{paths: pts,
strokeColor: '#FFFFFF',
strokeOpacity: 0.7,
strokeWeight: 0.5,
fillOpacity: 0.5,
fillColor: color
}
);
google.maps.event.addListener(quads, 'mouseover', function(event)
{
if (infowindow) infowindow.close();
infowindow = new google.maps.InfoWindow({content:
html});
infowindow.setPosition(latlng);
infowindow.open(map);
});
quads.setMap(map);
document.forms['QuadSelect'].quadSel.options[q] = new
Option(name,q); //poplulates drop down menu
//testing
//quads.cPt = latlng;
//quads.area = new google.maps.Polygon({paths: pts})
//quadArray.push(quads[q])
quadArray[q] = quads;
q++;
} //end createPolygon
function selectQuadZoom(qNum){
//var selectedQ =
viewQuad.options[viewQuad.selectedIndex].value;
/ map.setCenter(new
google.maps.LatLng(quadArray[selectedQ].cPt));
// map.setZoom(12);
var qBounds = new google.maps.LatLngBounds();
qBounds.extend(quadArray[qNum]);
map.fitBounds(qBounds);
//google.maps.event.trigger(quadArray[selectedQ], "click");
}
<form name="QuadSelect">
<select name="quadSel" id="quadSel"
onChange="selectQuadZoom(this.value)">
<option value=""></Option>
</select>
</form>