Tôi đã đọc tài liệu và ví dụ, nhưng có vẻ như tôi không thể giải quyết lỗi khởi tạo ("Tham chiếu không bắt buộc: google không được xác định" + Tham chiếu không bắt buộc: homeLatLng không được định nghĩa) khi cố gắng bao gồm tệp markerwithlabel.js và nó nhắc tôi nhớ đến "bạn không thể tải thứ gì đó trước khi bản đồ được thực hiện".API Google Maps: markerwithlabel.js - Tham chiếu không bắt buộcLỗi: google không được xác định
Tôi có thể làm gì?
gì đã cố gắng:
<head>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=mykey&callback=initMap"></script>
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel.js"></script>
<script type="text/javascript">
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: {lat: 52.5200066, lng: 13.404954}
});
var marker1 = 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
labelStyle: {opacity: 0.75}
});
}
</script>
..
này hoạt động hoàn hảo. (Cảm ơn bạn đã giải thích! – maxxyoo
Cảm ơn rất nhiều .--) Tôi đã lãng phí thời gian để cố gắng giải quyết. – user1355041
"http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel.js" không tồn tại. – Meysam