Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

html - Label Markers on rollover

brand new here.....don't hurt me :). I also apologize if my terminology is incorrect. I have no HTML experience but come here via FileMaker. I'm working on a FileMaker database just for my own small business and came across Geocoding, which I added to my database. Everything works fine. But I'm trying to figure out where in the HTML I could change the parameters so when I roll over a marker I can see the Customer's name, and not just "Marker 1". I was able to adjust the document so when I click on the marker, Name, Address, City State, etc. all pop up, but can't seem to figure out the marker (label?) part. If this is too much to ask, I apologize, and could you please just point me in the right direction.

I've been on this site and a few others over the past week, just reading & trying to learn all I can, and tinkering, but still remain stumped.

Any help/direction would be greatly appreciated. Of course if you need any more info just please ask.

Thanks Steve

PS Please note the below HTML is not something I created, just imported to my DB solution.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps Test</title>
<style type="text/css">
html, body {
   height: 100%;
   margin: 0;
   padding: 0;
}

#map_canvas {
  height: 100%;
}
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?                     sensor=false"></script>
<script type="text/javascript">
    function initialize() {
   var myOptions = {
    zoom: 5,
    center: new google.maps.LatLng(46.52863469527167,2.43896484375),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    mapTypeControlOptions: {
        mapTypeIds: [google.maps.MapTypeId.ROADMAP,     google.maps.MapTypeId.HYBRID]
    }
};

var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

var markerBounds    = new google.maps.LatLngBounds();
var markers         = new Array(
    [[MarkersArray]]
    );

var infoWindow = new google.maps.InfoWindow;    

function addMarker(options){
    var marker = new google.maps.Marker({map:map});
    marker.setOptions(options);

    google.maps.event.addDomListener(marker, 'click', function() {
        infoWindow.setContent(marker['info']);

        infoWindow.open(map, marker);
    });

    markerBounds.extend(options.position);

    return marker;
}

google.maps.event.addListener(map, 'click', function() {
    infoWindow.close();
});

var end = markers.length;
for(var i=0; i<end; i++) {
    addMarker({
        position: markers[i]['position'],
        title: "Marker "+i,
        info: markers[i]['info']
    });
}

map.setCenter(markerBounds.getCenter());
map.fitBounds(markerBounds);
}
</script>
</head>
<body onload="initialize()">
  <div id="map_canvas"></div>
</body>

</html>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The "title" of the marker is what is displayed on mouseover. It is being set by this code:

addMarker({
    position: markers[i]['position'],
    title: "Marker "+i,
    info: markers[i]['info']
});

Change the "Marker "+i to be the text you want displayed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...