Linking sidebar to map

78 views
Skip to first unread message

Am

unread,
Oct 27, 2011, 5:21:19 PM10/27/11
to google-map...@googlegroups.com
Hi,
I'm trying to make the results in the store locator sidebar link to the map. This way, I can click on the property address and it opens the bubble on the map. I have the address set up as a link, but nothing happens. Also, the bubble is linked, and I don't want that.
I wasn't able to find a tutorial to do this. How do I link my sidebar results to the map? Am I even doing it the right way?
http://www.rentalmatch101.com.php5-20.dfw1-1.websitetestlink.com/googlemap.php

Thank you for your help.

Am

unread,
Oct 27, 2011, 5:54:56 PM10/27/11
to google-map...@googlegroups.com
Ok, I got the links to work by changing markers.length-1 to markers.length-0.
How do I remove the link from the bubble? Can I even remove it?

Rossko

unread,
Oct 28, 2011, 5:01:38 AM10/28/11
to Google Maps JavaScript API v3
> How do I remove the link from the bubble? Can I even remove it?

One way would be to examine your own code, and discover how it gets
put there. You could then opt not to put it there.

Am

unread,
Oct 28, 2011, 8:41:32 AM10/28/11
to google-map...@googlegroups.com
When I put the code where I think it needs to go, it automatically adds it to the bubble. I don't know how else to do it, that's why I'm asking for help.

Andrew Leach

unread,
Oct 28, 2011, 8:51:36 AM10/28/11
to google-map...@googlegroups.com

Looks fine to me. The link in the sidebar opens the infoWindow, and
the infoWindow doesn't contain a link.

This seems to satisfy what you wrote earlier: "I'm trying to make the

Am

unread,
Oct 28, 2011, 8:54:29 AM10/28/11
to google-map...@googlegroups.com
I had to change infoWindow.setContent(html); to infoWindow.setContent(bubble);, and duplicate my variable with the name bubble instead of html, and remove the link from it.

var html = "<a href='javascript:myclick(" + (markers.length-0) + ")'><span style='font-weight:bold'>" + street + "<\/a></span> </p>"; // info window contents
var bubble = "<span style='font-weight:bold'>" + street + "</span></p>"; // info window contents


In case someone else needs help with the same issue. I received help from another source. Thanks for your help anyway.

Rossko

unread,
Oct 28, 2011, 9:05:25 AM10/28/11
to Google Maps JavaScript API v3
> I had to change infoWindow.setContent(html); to
> infoWindow.setContent(bubble);, and duplicate my variable with the name
> bubble instead of html, and remove the link from it.

Okaydokey, you found where the link was added and altered what
happens.

I would recommend that you define 'bubble' _before_ you set up the
listener that uses it, within your createMarker() function.

Am

unread,
Oct 28, 2011, 9:56:13 AM10/28/11
to google-map...@googlegroups.com
Thank you for the advice. I believe I have it defined:

function createMarker(googlemap_ltgooglemap_ln, street) {   
     
      var marker = new google.maps.Marker({
        map: map,
        position: googlemap_ltgooglemap_ln
      });
      google.maps.event.addListener(marker, 'click', function() {
        infoWindow.setContent(bubble);
        infoWindow.open(map, marker);
      });
      if (city){

         var html = "<a href='javascript:myclick(" + (markers.length-0) + ")'><span style='font-weight:bold'>" + street + "<\/a></span> </p>"; // info window contents
         var bubble = "<span style='font-weight:bold'>" + street + "</span></p>"; // info window contents
    } else {
        var html = street;
        var bubble = "";
    }
     sidebarInfo += html;
      // add this line after the html var declaration:
      document.getElementById("sidebar").innerHTML=sidebarInfo;
     
      markers.push(marker);
    }

I have an if statement for additional fields that I don't want displayed when there are no properties. I just don't have those fields listed in this example.

Rossko

unread,
Oct 28, 2011, 11:05:43 AM10/28/11
to Google Maps JavaScript API v3
>       google.maps.event.addListener(marker, 'click', function() {
>         infoWindow.setContent(bubble);

Here 'bubble' is referenced

>          var bubble = "<span style='font-weight:bold'>" + street +

Here 'bubble' is defined.

It would be good practice to define 'bubble' _before_ referencing it.
It's only a case of changing the order of statements.
In particular, different browsers are likely to behave differently in
this kind of ambiguous case.

Am

unread,
Oct 31, 2011, 11:56:34 AM10/31/11
to google-map...@googlegroups.com
Oh ok, I understand. Thank you for the advice.
Reply all
Reply to author
Forward
0 new messages