独自のマーカー(カスタムマーカー)を表示する

説明

マップ上に独自のマーカー(カスタムマーカー)を表示するにはgoogle.maps.Marker()で指定できるiconオプションを使います。iconオプションに表示したいマーカー画像のURLを指定します。

Google Maps APIプログラミング入門 Google Maps API プログラミング入門。Google Maps API Expertである勝又雅史氏が最新のAPI ver3やGoogle Maps for Flashなどについて解説しています。
アマゾンで購入する

サンプルコード [実行]

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>Google Maps API ver 3 Sample/グーグルマップAPIサンプル/Google Maps API样品</title>
<link rel="stylesheet" href="css/main.css" type="text/css" media="all">
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
</head>
<body>
<div id="gmap"></div>
<script type="text/javascript">
var map = new google.maps.Map(
document.getElementById("gmap"),{
zoom : 7,
center : new google.maps.LatLng(35.689160610317174, 139.70083951950073),
mapTypeId : google.maps.MapTypeId.ROADMAP
}
);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(35.689160610317174, 139.70083951950073),
map: map,
icon : "images/myMarker.png"
});
</script>
</body>
</html>