Łukasz Szczeciński
Łukasz Szczeciński

Reputation: 41

OnMapClickListener not called when click on polygon

I want to place marker inside polygon, so I need to know the click LatLng position. I have created OnMapClickListener like below:

mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {

            @Override
            public void onMapClick(LatLng latLng) {
                      Log.d("map","clickmap!");
            }
});

I get the log everytime I click outside the polygon but if inside, nothing happens.
Where is the problem?

Is there another way to get click position inside polygon? Unfortunately OnPolygonClickListener doesn't give the click location.

Upvotes: 1

Views: 665

Answers (1)

Łukasz Szczeciński
Łukasz Szczeciński

Reputation: 41

I have just got the answer.

The thing is that when I create PolygonOptions for my polygon I set "clickable = true". That was the reason I could not get OnMapClick call.

So, for anybody who will have the same problem - polygon must by not clickable.

Best regards Lukasz

Upvotes: 3

Related Questions