2011-08-09 2 views
0

지도, 검색 포트 및 확대/축소 위치에 배치 된 검색 결과가있을 때 매핑 서버 (geoServer)에있는 스트리밍 된지도의 클라이언트로 OpenLayers API를 사용하고 있습니다. 수준이 변경되지 않으면 결과 집합의 좌표 범위를 확대하여 원하는 모든 확대/축소 좌표에 맞게 확대/축소하려고합니다. 지도보기 포트를 변경하고 다른 좌표에 따라 확대/축소

나는 다음 코드 있지만, 값없이 .. lonLatMarker 개체의 어떤 종류의

var Newbounds= new OpenLayers.Bounds(); //global var 
Newbounds.extend(lonLatMarker);  // inside the function of setting the marker data  
map.zoomToExtent(Newbounds);  // after showing results set of coordinates on the map 

답변

2

입니다 시도?

당신이 올바른 개체 유형을 감안할 때 OpenLayers.Marker하지 OpenLayers.LonLat 될 경우,이 코드는 작동합니다 :

var newBounds = new OpenLayers.Bounds(lonLatMarker.lon, lonLatMarker.lat, lonLatMarker.lon, lonLatMarker.lat); 
map.zoomToExtent(newBounds); 
관련 문제