데이터베이스 결과를 기반으로 Google지도를 생성하려고합니다. 지오 코딩 된 주소를지도에 표시 할 수는 있지만 신속하게 처리 할 수는 없습니다. 마커를로드하는 데 도움이되는 setTimeout 함수가 있습니다. 포함하지 않으면 모든 마커가로드되지 않습니다.동적으로 Google 맵 마커로드 중
마커를 신속하게 푸시 할 수있는 방법이 있습니까? 마커에는 마침내 InfoWindows도 포함됩니다. 참고 : ColdFusion과 SQL을 사용하고 있습니다. Here is what happens. 여기 내 코드는 지금까지 있습니다 :
<body onLoad="initialize()">
<div id="map_canvas" class="grid_12">
</div>
</div>
<!end .container_12>
</body>
<script type="text/javascript">
function initialize(){
// Prepare the array from ColdFusion and database
var locations = [
<cfset locationArray=ArrayNew(1)>
<cfloop query="GetLocations">
<cfscript>
ArrayAppend(locationArray, #Client_Address# & ' ' & #Client_City# & ' ' & #Client_State# & ' ' & #Client_Company#);
</cfscript>
'<cfoutput>#Client_Address# #Client_City# #Client_State#</cfoutput>',
</cfloop>
];
//Set options of the google map
var mapOpt = {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(42.48019996901214, -90.670166015625),
zoom: 8
};
//Create new map
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOpt);
var geocoder = new google.maps.Geocoder();
var index = 0;
//Begin geocoding function converting addresses to LatLng
var geocoderFunction = function() {
geocoder.geocode({ 'address': locations[index] }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
new google.maps.Marker({
map: map,
position: results[0].geometry.location,
title: ''
});
}
// Call the geocoder with a 150ms delay
index++;
if (locations.length > index) {
setTimeout(geocoderFunction, 150);
}
});
}
// Launch the geocoding process
geocoderFunction();
}
</script>
</html>
나는이에서 아주 새로운, 그래서 어떤 도움을 주시면 감사하겠습니다!
여기에 내가 한 방법은 다음과 같습니다. http://anglerweb.com/fishingreports/Create 이 페이지는 낚시 보고서를 낚시 장소에 추가하는 데 사용됩니다. 기본적으로 낚시 장소를 찾아 클릭하여 선택해야합니다. 지도를 탐색 할 때 지체 후 낚시 마커가 표시됩니다. 모든 마커를 빠르게 표시합니다. – akonsu
페이지를로드 할 때 상위 문서가 빠르게로드됩니다. 지도가 잠시 걸리면 마커가 나타납니다. 그러나 부모 문서가로드되고지도로드가 시작될 때까지 CF는 작업을 마쳤습니다. 느린 부분은 부모로드 후 * 실행중인 것입니다. @LarsH는 이것을 최적화하려고하는 첫 걸음이 될 것이라고 지적했습니다. –