나는이 갈 수있는 유일한 방법은, 즉 레이블로 마커를 사용하여 원하는 라벨 마커의 모양을 변경하는 것입니다 생각합니다. 두 가지 아이디어가 있습니다.
1) 사용자 정의 모양과 텍스트가있는 수정 된 마커를 사용하십시오. Google Image Charts 및 Infographics (예 : here 또는 here)을 사용하여 생성 된 이미지 아이콘 하지만 the google API to create such icons is deprecated without remedy! Or isn't?? 혼란이 있습니다. 내 의견을 참조하십시오.
2) 사용 "마커의지도 텍스트를 구글"인터넷 검색으로 쉽게 찾을 markerwithlabel library(). 이 라이브러리를 사용하면 마커 아이콘이 있거나없는 레이블로 마커를 정의 할 수 있습니다. 당신이 마커 아이콘을 원하지 않는 경우, 단지 icon: {}
을 설정
var marker = new MarkerWithLabel({
position: homeLatLng,
draggable: true,
raiseOnDrag: true,
map: map,
labelContent: "$425K",
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
icon: {}
});
는 그럼 당신은 정상 마커로 작업 할 수 있습니다, 즉 마우스 오버 이벤트에 대한 InfoWindow는 추가!
Here is the example how to use this library for what you need.
경쟁 금지 코드 :
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>MarkerWithLabel Mouse Events</title>
<style type="text/css">
.labels {
color: red;
background-color: white;
font-family: "Lucida Grande", "Arial", sans-serif;
font-size: 10px;
font-weight: bold;
text-align: center;
width: 40px;
border: 2px solid black;
white-space: nowrap;
}
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?v=3&sensor=false"></script>
<!-- <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.9/src/markerwithlabel.js"></script>-->
<script type="text/javascript" src="markerwithlabel.js"></script>
<script type="text/javascript">
function initMap() {
var latLng = new google.maps.LatLng(49.47805, -123.84716);
var homeLatLng = new google.maps.LatLng(49.47805, -123.84716);
var map = new google.maps.Map(document.getElementById('map_canvas'), {
zoom: 12,
center: latLng,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var marker = new MarkerWithLabel({
position: homeLatLng,
draggable: true,
raiseOnDrag: true,
map: map,
labelContent: "$425K",
labelAnchor: new google.maps.Point(22, 0),
labelClass: "labels", // the CSS class for the label
icon: {}
});
var iw = new google.maps.InfoWindow({
content: "Home For Sale"
});
var ibOptions = {
content: 'content'
// other options
};
var ib = new google.maps.InfoWindow(ibOptions);
ib.open(map, this);
google.maps.event.addListener(marker, "mouseover", function (e) { ib.open(map, this); });
google.maps.event.addListener(marker, "mouseout", function (e) { ib.close(map, this); });
}
</script>
</head>
<body onload="initMap()">
<p>Try interacting with the marker (mouseover, mouseout, click, double-click, mouse down, mouse up, drag) to see a log of events that are fired. Events are fired whether you are interacting with the marker portion or the label portion.</p>
<div id="map_canvas" style="height: 400px; width: 100%;"></div>
</body>
</html>
@Tomas 마커 라벨 라이브러리는 모든 마커를 한 곳에 배치하고 있습니까? 어떻게 대응점에 각 마커를 표시 할 수 있습니까? – justin
@TMS : 모든 마커의 내용 상자가 한 곳에서옵니다. 이것은 버그인가요, 아니면 뭔가 빠졌는가? –
@JitendraPancholi 이것은 가능한 일을 보여주기위한 예일 뿐이므로이를 목적에 맞게 미세 조정해야 할 수도 있습니다. – TMS