다음 jQuery
과 같이 내 웹 페이지에 이미지를로드합니다 .
$(function () {
$('#mySelect').change(function () {
var selectedCity = $('#mySelect').val();
var myLatLng = new google.maps.LatLng(eval(selectedCity).lan, eval(selectedCity).lng);
venueMap.setCenter(myLatLng);
image = 'img.png';
marker = new google.maps.Marker({
position: myLatLng,
map: venueMap,
icon: image
});
marker.setMap(venueMap);
});
});
이미지의 너비와 높이는 어떻게 설정합니까?
나는 시도 image.width = 100;
했고 image.height = 50;
(js 문으로) 성공하지 못했습니다.
내 관련 HTML 코드를 묻습니다.
....
<body>
<center>
<h2>Testing jQuery with Google Maps</h2>
<br>
<br>
<select id="mySelect">
<option value="Rome">Rome</option>
<option value="London">London</option>
</select>
<br>
<br>
<div id="map"></div>
</center>
</body>
.....
Google지도 문서 에 표시된대로 이미지의 다른 속성을 추가 할 수 있습니다.
var image = {
url: 'image.png',
// This marker is 20 pixels wide by 32 pixels high.
size: new google.maps.Size(20, 32),
// The origin for this image is (0, 0).
origin: new google.maps.Point(0, 0),
// The anchor for this image is the base at (0, 32).
anchor: new google.maps.Point(0, 32)
};
도움이 되었기를 바랍니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다