문제는 내가 맞춤 아이콘을로드 할 수 없다는 것입니다. 마커 자체가로드되지만 기본 아이콘만으로로드됩니다. 아이콘을 설정하면로드 할 사용자 지정 아이콘을 얻을 수 있습니다. 다음과 같이 표식 개체에 수동으로 입력하십시오.Google지도에 맞춤 아이콘이 표시되지 않습니다.
var marker = new google.maps.Marker({
position: places[i],
map: map,
icon: sizeIcons['one']
})
그런 다음 모두 잘로드됩니다. 그러나 크기를 설정하여 KML 생성기에서 작동하는 아래 코드를 추가했지만 어떤 이유로 든 사용자 정의 아이콘을 생성하지 못합니다. 어떤 아이디어? 나는 모든 코드 만 $ 콘텐츠의 가치를 게시하지 않았다 [1] (50) 및 (450)
index.html을 사이의 숫자
$sizeFloat = (int) $content[1];
if($sizeFloat < 50){
?>
<script type="text/javascript">
markerType.push(sizeIcons['one']);
</script>
<?php
}
if($sizeFloat >= 50 && $sizeFloat < 70){
?>
<script type="text/javascript">
markerType.push(sizeIcons['two']);
</script>
<?php
}
if($sizeFloat >= 70 && $sizeFloat < 75){
?>
<script type="text/javascript">
markerType.push(sizeIcons['three']);
</script>
<?php
}
if($sizeFloat >= 75 && $sizeFloat < 88){
?>
<script type="text/javascript">
markerType.push(sizeIcons['four']);
</script>
<?php
}
if($sizeFloat >= 88 && $sizeFloat < 100){
?>
<script type="text/javascript">
markerType.push(sizeIcons['five']);
</script>
<?php
}
if($sizeFloat >= 100 && $sizeFloat < 125){
?>
<script type="text/javascript">
markerType.push(sizeIcons['six']);
</script>
<?php
}
if($sizeFloat >= 125 && $sizeFloat < 150){
?>
<script type="text/javascript">
markerType.push(sizeIcons['seven']);
</script>
<?php
}
if($sizeFloat >= 150 && $sizeFloat < 175){
?>
<script type="text/javascript">
markerType.push(sizeIcons['eight']);
</script>
<?php
}
if($sizeFloat >= 175 && $sizeFloat < 200){
?>
<script type="text/javascript">
markerType.push(sizeIcons['nine']);
</script>
<?php
}
if($sizeFloat >= 200 && $sizeFloat < 250){
?>
<script type="text/javascript">
markerType.push(sizeIcons['ten']);
</script>
<?php
}
if($sizeFloat >= 250 && $sizeFloat < 275){
?>
<script type="text/javascript">
markerType.push(sizeIcons['eleven']);
</script>
<?php
}
if($sizeFloat >= 275 && $sizeFloat < 350){
?>
<script type="text/javascript">
markerType.push(sizeIcons['twelve']);
</script>
<?php
}
if($sizeFloat >= 350){
?>
<script type="text/javascript">
markerType.push(sizeIcons['thirteen']);
</script>
<?php
}
if ($content !== false) {
?>
<script type="text/javascript">
places.push(new google.maps.LatLng(<?php echo json_encode($content[5]); ?>, <?php echo json_encode($content[6]); ?>));
</script>
<?php
}
$id = $id + 1;
}
fclose($file);
}
?>
<script type="text/javascript" src="js/map.js"></script>
map.js 나 '
(function() {
// Creating a variable that will hold the InfoWindow object
var infowindow;
// Creating an array that will contain all the size icons
var sizeIcons = [];
sizeIcons['one'] = new google.maps.MarkerImage(
'images/25.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['two'] = new google.maps.MarkerImage(
'images/50.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['three'] = new google.maps.MarkerImage(
'images/70.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['four'] = new google.maps.MarkerImage(
'images/75.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['five'] = new google.maps.MarkerImage(
'images/88.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['six'] = new google.maps.MarkerImage(
'images/100.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['seven'] = new google.maps.MarkerImage(
'images/125.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['eight'] = new google.maps.MarkerImage(
'images/150.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['nine'] = new google.maps.MarkerImage(
'images/175.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['ten'] = new google.maps.MarkerImage(
'images/200.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['eleven'] = new google.maps.MarkerImage(
'images/250.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['twelve'] = new google.maps.MarkerImage(
'images/275.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
sizeIcons['thirteen'] = new google.maps.MarkerImage(
'images/425.png',
new google.maps.Size(48, 48),
null,
new google.maps.Point(24, 24)
);
window.onload = function() {
// Creating an object literal containing the properties
// we want to pass to the map
var options = {
zoom: 5,
center: new google.maps.LatLng(39.09, -95.71),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// Creating the map
var map = new google.maps.Map(document.getElementById('map'), options);
// Creating a LatLngBounds object
var bounds = new google.maps.LatLngBounds();
// Creating a variable that will hold
// the InfoWindow object
var infowindow;
// Looping through the places array
for (var i = 0; i < places.length; i++) {
// Adding the markers
var marker = new google.maps.Marker({
position: places[i],
map: map,
icon: markerType[i]
});
// Wrapping the event listener inside an anonymous function
// that we immediately invoke and passes the variable i to.
(function(i, marker) {
// Creating the event listener. It now has access to the values of
// i and marker as they were during its creation
google.maps.event.addListener(marker, 'click', function() {
// Check to see if we already have an InfoWindow
if (!infowindow) {
infowindow = new google.maps.InfoWindow();
}
// Setting the content of the InfoWindow
infowindow.setContent('Place number ' + i);
// Tying the InfoWindow to the marker
infowindow.open(map, marker);
});
})(i, marker);
// Extending the bounds object with each LatLng
bounds.extend(places[i]);
}
// Adjusting the map to new bounding box
map.fitBounds(bounds)
};
})();
스프라이트 사용에 대해 생각했지만 누군가 이미 13 개의 작은 아이콘을 만들었습니다. 또한 icon : sizeIcons [ 'three']에 수동으로 입력 할 때 제대로 작동합니다. 그것은 크기를 확인하고 다시 작동을 멈추는 배열 정보를 보내려고 할 때입니다 – shinjuo
나는 문제를 알아 냈습니다. 도움을 주셔서 감사합니다. – shinjuo
문제를 일으킨 원인 및/또는 해결 방법을 공유하십시오. 당신이 그랬다면 나머지 웹 사이트에 도움이 될 것입니다. 당신은 다른 사람이 당신이 한 똑같은 문제에 대하여 언제 올거 모르고 해결해야 할지를 결코 알지 못합니다. 그렇게 할 경우이 질문에 대한 답변으로 추가하고 ** 답변 **으로 정답으로 표시해야합니다. 내 것이 아니야. – sholsinger