InfoWindow.open and Circle

1,215 views
Skip to first unread message

Lukasz Jaroszewski

unread,
Nov 4, 2010, 11:15:38 AM11/4/10
to Google Maps JavaScript API v3
Hi,
I am trying to put infowindow at Circle `marker' and it doesnt work
with google.maps.Circle tho it works prefectly with
google.maps.Marker.
I dunno what I am doing wrong with it. I can see alert("CKICK"); after
clicking Circle, for some reason content of infowindow shows for
milisecond in topleft corner which I can spot only in DW LiveView
inbuilt browser.

here is the site: http://www.salag.com/maps

Thanks in advance for help.

BRGRDS
L.

<cut>

if (!marker) {

marker = new google.maps.Circle({
map: map,
strokeOpacity: 0,
fillColor: "#FF0000",
clickable: true
});
}

//marker.setPosition(results[0].geometry.location);
marker.setCenter(results[0].geometry.location);
marker.setRadius(10000);

</cut>

<cut>
google.maps.event.addListener(marker, "click", function () {
infowindow.setContent(content);
infowindow.open(map,marker);
alert("CKICK");
});
</cut>
Message has been deleted

Esa

unread,
Nov 4, 2010, 8:23:52 PM11/4/10
to Google Maps JavaScript API v3

Chris Broadfoot

unread,
Nov 4, 2010, 9:14:50 PM11/4/10
to google-map...@googlegroups.com

Check the docs for InfoWindow. InfoWindow.open works with any MVCObject that exposes 'position'. Circle is not one such MVCObject. Its center point is not exposed as its 'position'.

As such, if you'd like to open an InfoWindow at the center, you'll want something like:

infowindow.open(map, circle.getCenter())

(assuming you rename your variable to 'circle'... after all, it's not a Marker :)

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

Chris Broadfoot

unread,
Nov 4, 2010, 9:23:48 PM11/4/10
to google-map...@googlegroups.com
oops, sorry, that's wrong, too...

LatLng is not an MVCObject that exposes 'position' property :)

infowindow.setPosition(circle.getCenter());
infowindow.open(map);

Lukasz Jaroszewski

unread,
Nov 5, 2010, 3:58:55 AM11/5/10
to Google Maps JavaScript API v3


On 5 Lis, 01:23, Esa <esa.ilm...@gmail.com> wrote:
> Thanks for the link, but it gives 404
>
> http://www.salag.com/maps&usg=AFQjCNH8HJfTUHUQP4LOGCOnPPdqR4NRaQ


sorry typo: http://www.salag.com/map

Lukasz Jaroszewski

unread,
Nov 5, 2010, 4:15:37 AM11/5/10
to Google Maps JavaScript API v3
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>
> > .
> > > For more options, visit this group at
> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Thanks for claryfying. I have checked docs and I had to miss lines
that Circle does not expose position.

ad. var name, I played with other options for marking a spot thats why
I left it as marker.;-)


One more time thanks for help, next time I will read ref.docs more
carefully.

BRGRDS
L.
Reply all
Reply to author
Forward
0 new messages