I am about to create a google map script, where i can set locations (not lat and lng) but locations in the google map, so it shows a picture on that location, and when mouseover it should open a overlay with picture + text.
I have the script to show 1 address, but how to implementate more than 1? Like an array ["London", "Odense C, Danmark", "something"] ?
And the pointer should be a image (costum image) and not the point of default google map. I've tried this, but it doesn't show anything. Please help me!
$(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!
});
}
});