我只是想知道,我如何在坐标(38.0,-98.0)和坐标(45.0,-100.0)的另一个标记处添加标记到我正在制作的自定义Google地图?到目前为止,这是我的代码:
<script type="text/javascript">
var map;
var grayStyles = [
{
featureType: "all",
stylers: [
{ saturation: -100 },
]
},
];
var mapOptions = {
center: new google.maps.LatLng(38, -98),
zoom: 5,
styles: grayStyles,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
function initialize() {
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
</script>
答案 0 :(得分:2)
简单标记:
var marker1 = new google.maps.Marker({
position: new google.maps.LatLng(38.0, -98.0),
map: map,
});
var marker2 = new google.maps.Marker({
position: new google.maps.LatLng(45.0, -100.0),
map: map,
});
答案 1 :(得分:0)
这是我使用的代码,放在行
之后map = new google.maps.Map(documen......
并且您可以多次重复此代码以获得更多标记
var ncenter = new google.maps.LatLng(parseFloat('52.43598') , parseFloat('16.94412')); /* this is the position */
var image = {
url: '/img/xspot.png',
// This marker is 20 pixels wide by 32 pixels tall.
size: new google.maps.Size(115, 86),
// The origin for this image is 0,0.
origin: new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
anchor: new google.maps.Point(57, 71)
}; /* You can ignore the image mark */
var beachMarker = new google.maps.Marker({
position: ncenter,
map: map,
icon: image // if you ignore image related code above, also remove this line
});