我即将创建一个谷歌地图脚本,我可以在其中设置位置(不是纬度和经度),而是在谷歌地图中设置位置,因此它会在该位置显示一张图片,当鼠标悬停时它应该打开一个带有图片+文字的叠加层。
我有显示 1 个地址的脚本,但是如何实现超过 1 个?像一个数组 ["London", "Odense C, Danmark", "something"] ?
并且指针应该是图像(服装图像)而不是默认谷歌地图的点。我试过这个,但它没有显示任何东西。请帮我!
$(function () {
var geocoder = new google.maps.Geocoder();
function getPosition(address) {
geocoder.geocode({
"address": address
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//Create the popup etc..
var contentString = '<div id="
content "><div id="
siteNotice "></div><h2 id="
firstHeading " class="
firstHeading ">dsfdf</h2><div id="
bodyContent "><p>Some text in here</p></div></div>';
var infowindow = new google.maps.InfoWindow({
content: contentString
});
google.maps.event.addListener(marker, "mouseover", function () {
infoWindow.open(map, marker);
});
return results[0].geometry.location;
}
});
}
if ($("div#map").length) {
// google map
var name = "Stolen property";
var address = "Odense, Denmark";
geocoder.geocode({
"address": "Odense Danmark"
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 15,
center: results[0].geometry.location,
mapTypeId: google.maps.MapTypeId.ROADMAP,
scrollwheel: false,
disableDefaultUI: true
});
//Create 1
var marker = new google.maps.Marker({
position: getPosition("Brogade Odense Danmark"),
map: map,
title: name
});
//Create two!
var marker = new google.maps.Marker({
position: getPosition("Skibhusvej Odense Danmark"),
map: map,
title: name
});
}
//Add it!
});
}
});