如何在Google地图上放置地标?

Gur*_*uru 3 javascript google-maps

如何在Google地图上放置地标?

下面的代码只显示了特定的位置,但我想在谷歌地图上添加我自定义的地方标记图像.

<!DOCTYPE html>
<html>
<head>
<script
src="http://maps.googleapis.com/maps/api/js?key=MyKey&sensor=false">
</script>

<script>
function initialize()
{

var mapProp = {
  center:new google.maps.LatLng(23.0300,72.5800),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
 } 
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:500px;height:380px;"></div>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

The*_*per 5

以下是Google Maps Marker的示例:

var myMarker = new google.maps.Marker({
position: new google.maps.LatLng(31.1287, -94.9594117), // Example Lat/Long
map: map, // references the map object you defined earlier
title: 'My custom Title', // a title that will appear on hover
    icon: 'images/googleMap/icon-star.gif' // Optional Marker Icon to use
});
Run Code Online (Sandbox Code Playgroud)

您可以在Google地图的Google地图文档中找到更多信息:简单标记

祝你好运!:)