나는 내 지역에서 범죄 활동을 계획하기 위해 Google지도에서 작업하고 있습니다. 그것은 작동하지만 지금은 같은 페이지에서 양식을 사용하여 거리 이름, 날짜 범위, 자연 등을 필터링하려고합니다.Google지도 새로 고침
여기 https://developers.google.com/academy/apis/maps/visualizing/earthquakes에있는 자습서를 따랐습니다.
jsonp 피드를 데이터 소스로 사용합니다.
script.src = 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week'
나는 맞춰 내 지역에서 범죄 데이터를 반환 "process_request.php"라는 스크립트를 만들었습니다.
필터/양식 기준을 적용하는 방법이 분실되었습니다. 그래서 여기 내 질문은 ... 내가 AJAX를 사용하여 window.eqfeed_callback을 업데이트해야합니까? 양식 동작이 "index.php"또는 "process_request.php"여야합니까? 내 양식에 onsubmit="refreshMap();"
을 사용해야합니까?
<script>
var map;
function initialize() {
var mapOptions = {
zoom: 13,
center: new google.maps.LatLng(37.749919,-68.869871),
mapTypeId: google.maps.MapTypeId.TERRAIN
};
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
// Create a <script> tag and set the USGS URL as the source.
var script = document.createElement('script');
// (In this example we use a locally stored copy instead.)
// script.src = 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week';
script.src = 'https://example.com/crime/process_request.php';
document.getElementsByTagName('head')[0].appendChild(script);
}
// Loop through the results array and place a marker for each
// set of coordinates.
window.eqfeed_callback = function(results) {
var infowindow = new google.maps.InfoWindow();
for (var i = 0; i < results.features.length; i++) {
var coords = results.features[i].geometry.coordinates;
var latLng = new google.maps.LatLng(coords[0],coords[1]);
var weight_factor = results.features[i].properties.weight;
var marker = new google.maps.Marker({
position: latLng,
map: map,
icon: getCircle(weight_factor),
});
google.maps.event.addListener(marker,'click', (function(marker, i) {
return function() {
infowindow.setContent('<strong>Address:</strong> ' + results.features[i].properties.address + "<br><strong>Total Reports:</strong> "+ results.features[i].properties.weight + "<br><strong>Nature:</strong> " + results.features[i].properties.nature);
infowindow.open(map, marker);
}
})(marker, i));
}
}
function getCircle(weight_factor) {
return {
path: google.maps.SymbolPath.CIRCLE,
fillColor: 'red',
fillOpacity: .3,
scale: weight_factor * 3, //Math.pow(2, magnitude)/Math.PI,
strokeColor: 'white',
strokeWeight: .8
};
}
</script>