を確認し、返信してください。
Googleが提供するdocumentationを参考にして、マップに追加する画像ごとに以下のインスタンスを作成する必要があります。以下の例は、google.maps.Map
オブジェクトを作成し、それをmap
というjavascript変数に割り当てたと仮定しています。あなたが見ることができるように
var location = new google.maps.LatLng(-0.127985, 51.507877) ;
var marker = new google.maps.Marker({
position: location,
icon: "https://example.com/images/myImage.png",
map: map
}) ;
は、google.maps.Marker
オブジェクトは、あなたのイメージを指すURLとgoogle.maps.LatLng
オブジェクトとして緯度と長いが必要です。
[EDIT]
はちょうど私があなたに簡単な例をドロップしようと思いました。プロットするアイテムのリストなど、これはあなたの後ろのものとは異なる場合がありますが、Googleマップ上に画像を配置し、独自の変更を行うための基礎として機能することを明確に理解する必要があります。
<html>
<head>
<style>
#map-here {
width: 400px ;
height: 400px ;
border-radius: 3px ;
}
</style>
</head>
<body>
<div id="map-here"></div>
<script>
function wrapper() {
addMapWithMarker({
'coords': [ 51.507877, -0.127985 ],
'image': 'https://maps.google.com/mapfiles/kml/shapes/info-i_maps.png',
}, 'map-here') ;
function addMapWithMarker(args, id) {
var map = new google.maps.Map(
document.getElementById(id), {
zoom: 16,
mapTypeId: google.maps.MapTypeId.TERRAIN,
disableDefaultUI: true,
zoomControl: true,
mapTypeControl: true,
scaleControl: false,
streetViewControl: false,
rotateControl: false,
fullscreenControl: false,
center: { lat: args.coords[0], lng: args.coords[1] },
}
) ;
var infoMarker = new google.maps.Marker({
position: { lat: args.coords[0], lng: args.coords[1] },
icon: args.image,
map: map,
title: "Lord Nelson",
});
}
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=<api-key>&libraries=visualization&callback=wrapper"></script>
</body>
</html>
<api-key>
をAPIキーに置き換えてください。
[END EDIT]
私はおそらくあなたが望む方法であなたのメッセージを編集しました。これがあなたの意図したものでない場合は、自由にロールバックしてください。 –