건물 옥상에서 측정을 수행하기 위해 GeoPortal이라는 Google Maps Geometry 용 플러그인을 사용하고 있습니다.Google Maps Geometry와 포인트 기억하기
내 응용 프로그램에 제대로 작동하는 플러그인이있어 입력 한 주소에서 동적으로 만들어진 이전 페이지의 경도 및 위도를 선택합니다.
내가 겪고있는 문제는 사람들이 응용 프로그램을 통해 앞뒤로 탐색 할 수 있어야한다는 것입니다. 즉, 영역 플롯을 기억해야하므로 다시 페이지를 탐색 할 때 다시 그리지 않아도됩니다. 지역마다. 예에서
나는 사람이 다시 페이지를 탐색 할 때이 플롯 레이아웃을 기억해야합니다
다음과 같이 내 코드는 다음과 같습니다
jQuery를
var map; var measure = { mvcLine: new google.maps.MVCArray(), mvcPolygon: new google.maps.MVCArray(), mvcMarkers: new google.maps.MVCArray(), line: null, polygon: null }; jQuery(document).ready(function() { map = new google.maps.Map(document.getElementById("map"), { zoom: 21, center: new google.maps.LatLng(51.502378,-0.114348), mapTypeId: google.maps.MapTypeId.HYBRID, draggableCursor: "crosshair" }); google.maps.event.addListener(map, "click", function(evt) { measureAdd(evt.latLng); }); }); function measureAdd(latLng) { var marker = new google.maps.Marker({ map: map, position: latLng, draggable: true, raiseOnDrag: false, title: "Drag me to change shape", icon: new google.maps.MarkerImage("http://maps.co.mecklenburg.nc.us/geoportal/img/measure-vertex.png", new google.maps.Size(9, 9), new google.maps.Point(0, 0), new google.maps.Point(5, 5)) }); measure.mvcLine.push(latLng); measure.mvcPolygon.push(latLng); measure.mvcMarkers.push(marker); var latLngIndex = measure.mvcLine.getLength() - 1; google.maps.event.addListener(marker, "mouseover", function() { marker.setIcon(new google.maps.MarkerImage("http://maps.co.mecklenburg.nc.us/geoportal/img/measure-vertex-hover.png", new google.maps.Size(15, 15), new google.maps.Point(0, 0), new google.maps.Point(8, 8))); }); google.maps.event.addListener(marker, "mouseout", function() { marker.setIcon(new google.maps.MarkerImage("http://maps.co.mecklenburg.nc.us/geoportal/img/measure-vertex.png", new google.maps.Size(9, 9), new google.maps.Point(0, 0), new google.maps.Point(5, 5))); }); google.maps.event.addListener(marker, "drag", function(evt) { measure.mvcLine.setAt(latLngIndex, evt.latLng); measure.mvcPolygon.setAt(latLngIndex, evt.latLng); }); google.maps.event.addListener(marker, "dragend", function() { if (measure.mvcLine.getLength() > 1) { measureCalc(); } }); if (measure.mvcLine.getLength() > 1) { if (!measure.line) { measure.line = new google.maps.Polyline({ map: map, clickable: false, strokeColor: "#FF0000", strokeOpacity: 1, strokeWeight: 3, path:measure. mvcLine }); } if (measure.mvcPolygon.getLength() > 2) { if (!measure.polygon) { measure.polygon = new google.maps.Polygon({ clickable: false, map: map, fillOpacity: 0.25, strokeOpacity: 0, paths: measure.mvcPolygon }); } } } if (measure.mvcLine.getLength() > 1) { measureCalc(); } } function measureCalc() { var length = google.maps.geometry.spherical.computeLength(measure.line.getPath()); jQuery("#span-length").text(length.toFixed(1)) if (measure.mvcPolygon.getLength() > 2) { var area = google.maps.geometry.spherical.computeArea(measure.polygon.getPath()); jQuery("#span-area").text(area.toFixed(1)); document.getElementById('RoofArea').value = area.toFixed(1); document.getElementById('submit').disabled = false; } } function measureReset() { if (measure.polygon) { measure.polygon.setMap(null); measure.polygon = null; } if (measure.line) { measure.line.setMap(null); measure.line = null } measure.mvcLine.clear(); measure.mvcPolygon.clear(); measure.mvcMarkers.forEach(function(elem, index) { elem.setMap(null); }); measure.mvcMarkers.clear(); jQuery("#span-length,#span-area").text(0); document.getElementById('submit').disabled = true; }
HTML/CSS
<style>
#map {
width: 500px;
height: 400px;
margin: 0 auto;
border: 5px solid #2F4B9E;
}
</style>
<div>
<div id="map"></div>
<p>Length (red line): <span id="span-length">0</span> mt<br />
Area (grey area): <span id="span-area">0</span> mt²<br />
<a href="javascript:measureReset();">Reset Measure</a></p>
</div>
아, 문제가 아닌 경도 및 위도 값을 저장합니다. Lon/Lat는 사람이 자신의 영역을 그려주는 건물을 대상으로합니다. Lon/Lat가 아닌 ** 면적 도면 **을 기억해야합니다. 당신이 나에게 말하지 않는다면, 이것도 영역 그리기 플롯을 저장하는데 사용할 수 있습니다; 그렇다면 어떻게 관리하나요? * E : 가능한 한 보편적이어야하므로 HTML5에서 멀리하고 싶습니다. * *'EE : 도움이 필요하면 조금 더 명확하게 질문을 업데이트했습니다. * –
If 페이지 세션의 위치 만 캐시하면되고 실제 새로 고침은 필요 없으며 JavaScript 객체에 저장할 수 있습니다. 페이지 새로 고침 사이의 위치를 유지해야하는 경우 서버 측 데이터베이스 솔루션을 사용해야합니다. 죄송합니다. 귀하의 문제를 이해하지 못하면 ... –
안녕하세요, Tim, 아니요, 제 질문에 대해 잘 이해하고 있습니다. 문제를 데이터베이스에 게시하기 위해 값을 가져 오는 * 것입니다. –