Simulate click on center of the map

303 views
Skip to first unread message

Ucha Dzodzuashvili

unread,
Jul 5, 2010, 6:42:14 AM7/5/10
to Google Maps JavaScript API v3
Hi all

Is there any way to simulate click on the center of the map from
button? map.getCenter()

Idea is that i would like to invoke klick event on the poygon that is
currently under center of the map!


Lost almost 6 houls struggling to implement it... last i did something
like that:

<img id="fixImg" src="img/restock.png" style="position: absolute;
width: 50px; left: 2px; top: 126px; z-index: 1100"
onclick="google.maps.event.trigger(map,'click', null,
map.getCenter());"/>

geoco...@gmail.com

unread,
Jul 5, 2010, 8:30:43 AM7/5/10
to Google Maps JavaScript API v3
On Jul 5, 3:42 am, Ucha Dzodzuashvili <ucha.dzodzuashv...@gmail.com>
wrote:
> Hi all
>
> Is there any way to simulate click on the center of the map from
> button? map.getCenter()
>
> Idea is that i would like to invoke klick event on the poygon that is
> currently under center of the map!

If you want to click on a polygon that has a click listener, then you
want to trigger a click event on the polygon, not "simulate a click on
the center of the map".

Do you have a reference to the polygon?

>
> Lost almost 6 houls struggling to implement it... last i did something
> like that:
>
> <img id="fixImg" src="img/restock.png" style="position: absolute;
> width: 50px; left: 2px; top: 126px; z-index: 1100"
> onclick="google.maps.event.trigger(map,'click', null,
> map.getCenter());"/>

Where is your map?
http://groups.google.com/group/google-maps-js-api-v3/t/2b3f101fd509919e

-- Larry

Ucha Dzodzuashvili

unread,
Jul 5, 2010, 9:59:47 AM7/5/10
to Google Maps JavaScript API v3
Yes there is a reference to the polygon,

But as there are lots of polygons i want click event triggered on the
one thet is in the center of map... i do not think thre is any native
function to determine weather some latlon belongs (is in area of)
polygon...

So if i do not invoke klick on the map at latlng or xy i will have to
enroll in geometry in order to determine which polygons the center
point lies in...

On Jul 5, 4:30 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Jul 5, 3:42 am, Ucha Dzodzuashvili <ucha.dzodzuashv...@gmail.com>
> wrote:
>
> > Hi all
>
> > Is there any way tosimulateclickon the center of the map from
> > button? map.getCenter()
>
> > Idea is that i would like to invoke klick event on the poygon that is
> > currently under center of the map!
>
> If you want toclickon a polygon that has aclicklistener, then you

Rossko

unread,
Jul 5, 2010, 3:57:32 PM7/5/10
to Google Maps JavaScript API v3
> But as there are lots of polygons i want click event triggered on the
> one thet is in the center of map...  i do not think thre is any native
> function to determine weather some latlon belongs (is in area of)
> polygon...

True, but that doesn't stop you adding a function to determine if
polygon contains point x,y
Example
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/734bbdd35614fefa/b6f78c71d3dc3846

Ucha Dzodzuashvili

unread,
Jul 7, 2010, 12:18:31 AM7/7/10
to Google Maps JavaScript API v3
THX rossko

That really helped!
adding that function was matter of couple of minutes! i will post code
on that link
> Examplehttp://groups.google.com/group/google-maps-js-api-v3/browse_thread/th...
Reply all
Reply to author
Forward
0 new messages