最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Maps: How does Trulia create their custom InfoWIndows? - Stack Overflow

programmeradmin1浏览0评论

I really like how Trulia has created their custom Google Map InfoWindows.

What I like in particular about Trulia's implementation of the InfoWindow is:

  • Extends beyond the map border: Google Maps InfoWindows are contained within the map border whereas Trulia's seems to be able to float on-top of the map
  • Always displays InfoWindow near map Center: Google Maps InfoWindows always display the InfoWindow above the marker whereas Trulia InfoWindows always display the InfoWindow as close the center of the map as possible. For example, if the map marker icon is on the top of the map near the border, the Trulia InfoWindow is displayed below the map marker icon
  • InfoWindow is displayed on mouse hover (not 'click'): With the default Google Maps InfoWindow, you have to 'click' the map marker icon to display the InfoWindow whereas Trulia InfoWindows are display simply by hovering over the map marker icon.

I found the PdMarker, which is a 3rd party extension for Google Map InfoWindows that acplishes most of the above bullets but not all. 1) It does not extend beyond the map border, 2) it does not work with Google Maps API version 3 (only version 2).

Anyone know how Trulia is acplishing their InfoWindow-like implementation on Google Maps API v3?

I really like how Trulia. has created their custom Google Map InfoWindows.

What I like in particular about Trulia's implementation of the InfoWindow is:

  • Extends beyond the map border: Google Maps InfoWindows are contained within the map border whereas Trulia's seems to be able to float on-top of the map
  • Always displays InfoWindow near map Center: Google Maps InfoWindows always display the InfoWindow above the marker whereas Trulia InfoWindows always display the InfoWindow as close the center of the map as possible. For example, if the map marker icon is on the top of the map near the border, the Trulia InfoWindow is displayed below the map marker icon
  • InfoWindow is displayed on mouse hover (not 'click'): With the default Google Maps InfoWindow, you have to 'click' the map marker icon to display the InfoWindow whereas Trulia InfoWindows are display simply by hovering over the map marker icon.

I found the PdMarker, which is a 3rd party extension for Google Map InfoWindows that acplishes most of the above bullets but not all. 1) It does not extend beyond the map border, 2) it does not work with Google Maps API version 3 (only version 2).

Anyone know how Trulia is acplishing their InfoWindow-like implementation on Google Maps API v3?

Share Improve this question edited Apr 7, 2010 at 16:51 NickT asked Apr 7, 2010 at 15:59 NickTNickT 4211 gold badge5 silver badges8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

That's an interesting question. I've been playing with maps recently too. I'm far from expert but I can tell you what I know.

I think the site you mentioned uses a custom div overlay rather than google's info window.

1. InfoWindow is displayed on mouse hover (not 'click')

This can be done with event listeners. For example in maps API v3:

google.maps.event.addListener(marker, 'mouseover', function() {
   // myDiv.style.visibility = 'visible'
});
google.maps.event.addListener(marker, 'mouseout', function() {
  // myDiv.style.visibility = 'hidden'
});

Here's is a pretty good example of how this can be done.

2. Extends beyond the map border
3. Always displays InfoWindow near map Center

Both of these can be achieved using CSS: (2) using z-index and (3) with position.

There is a similar example of using custom marker tooltips which you can find here. It also shows how you can utilize mouseovers to pop-up tooltips by hovering other elements on your page.

myElement.onmouseover = function(){
  google.maps.event.trigger(marker, 'mouseover');
}
myElement.onmouseout = function(){
  google.maps.event.trigger(marker, 'mouseout');
}

Finally, another site that makes a good use of maps, although this one uses V2 of the API. Hope this helps.

http://google-maps-utility-library-v3.googlecode./svn/trunk/infobox/docs/examples.html

is an extension to google maps which allows you to create custom infowindows

发布评论

评论列表(0)

  1. 暂无评论