开发者

Google Maps - 'Return to last result' not working

This is v2.

Here's how to reproduce the problem:

  1. go to h开发者_如何学JAVAttp://tweetmyjobs.com/tweetmaps/24419/branded
  2. Click on the 'New Mexico' pin
  3. In the popup, click 'CLICK HERE'
  4. when zoomed in, clicking the middle pan control (aka 'return to last result') does nothing. I'd like to return to the state view... (with NM in the centre, or whatever position it was before zooming in)

Any idea where should I even start looking (yes, I am that clueless in this case).


The problem here is that you are navigating to a new page to show the zoomed in map - so according to the zoomed-in map, there is no 'last result' to go to.

What you need to do is bind an event to the 'Click here to zoom in' link's onclick event. If you use jQuery then you can simply do: $("#clickLinkId").click(function(e) { ... }) but if you're using conventional JavaScript then you can do the following to set up an event listener:

var link = document.getElementById("#clickLinkId");
link.onclick = function(e){ ... }

In whatever handler you have, you want to use the Google Maps API to set the map's centre location and zoom level to what it is you want. In all cases, you'd want to have something like e.preventDefault() or return false on the click's event handler so that it doesn't try to navigate the page away.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜