Google Map - Which event when click on a place - google-maps

Sorry for my bad English!
I have spent more than a day for web search about this, but i have not found the solution yet. Please give me a suggestion.
I'm now working with google maps api. I've got a place autocomplete sample here: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
As the attached image, the place autocomplete feature works perfectly. When I enter the key word [Sydney distance education] --> click on the first suggestion --> the marker was moved to the specified place. I can get more detailed information from the marker variable.
This is the screen: http://www.imagesup.net/pt-1314056232011.png
When i click to the specified place on the map, it display a InfoWindow. I don't know which event should I need to listen to help me getting more detailed information of that place.
I have tried this
google.maps.event.addListener(map, 'click', function(event) {
alert('OK');
});
But the event is fired only when I click to another location which does not have viewport

Related

How to properly hide markers in google maps?

I am trying to add a bunch of markers to a map with show/hide buttons for each category of markers. Adding a marker from stored db data puts them on the map and makes them clickable, but they won't respond to setMap(null) unless that call is through google.event.addListener(marker, ...). Calling it from a standard js button onclick event, or via google.event.addDomListener(marker, ...) doesn't work.
Also maybe helpful to note is that when I call marker.setAnimation(BOUNCE) the marker starts bouncing but it looks like there is a duplicate marker under it. Similarly, if I drag the marker it's as if an unmovable duplicate is created right under it.
Thoughts? This is super frustrating!
Just like this taken from here ? Are you trying to avoid google maps api's google.maps.event.addDomListener? Why? You can use it to listen to your button's click event too. just as in:
var YourButton = document.getElementById('myButton');
function HideMarkers() {
// Hide us
}
google.maps.event.addDomListener(YourButton, 'click', HideMarkers);
customized for you from. For the second part, seeming like double markers I suppose we need some code..
This turned out to be purely user error. I am using firebase to store map data without a server backend and was adding duplicate markers. This explains the "inability to hide" and also the appearance of duplicate markers when dragging or animating.
The reason it was working from a click event on the marker was that both duplicate markers were receiving the click event and so both were being hidden.
setMap appears to be perfectly reliable when used in or out of google event handlers.

Google Map link to markers from external site

i have a question. My website has link Show on Map that points to custom google map. That custom google map has 30ish markers, and when you click link from website, it opens that map, and focuses corresponding marker there. So you use show on map for marker 1, custom map opens and focuses marker 1 with info bubble.
link is here
Show on map
link to map
Now, since i need to replicate that Google Map because i dont have acess to it anymore, i am wondering how to get link to certain marker? Since website doesnt have any javascript or anything regarding Goolge Maps, are those links hardcoded on custom map in source code or something? Since i know iwloc and coordiantes change on links.. But on source code of that custom map iwloc is same on 3-4 ocurrances in page.
Any help is welcome. I tryed to search here but everyone makes some javascript solution. I want it to be like now... only link to that marker. Thanks
Open the specific map, open the desired infoWindow(by clicking on the marker or on an item in the sidebar) and then copy the short URL that will be shown when you click the share-button(in the top-right corner of the sidebar)

How can i capture the click event when a default marker/place is clicked on googlemaps?

I am working with Google Maps API V3. The googlemaps displays markers for some places/location by default, I need to capture the click event when one of them is clicked..
I have tried to use the click event of the map but it not works because the user is clicking the marker not the map, code is given:
google.maps.event.addListener(mymap, 'click', function () {
alert('clicked');
});
Can someone give me an idea how to do it?
EDIT:
I can find no suitable Event in the available Events, which can help me!
Please note that I am not talking about the custom Markers (Created by User), these are default markers, googlemaps displays them by default.
Here's a clean solution straight from Google:
https://developers.google.com/maps/documentation/javascript/examples/event-poi
You can easily customize the default infowindow for POI's. Just ignore the route-making feature of the tutorial.
I have never tried it but could you retrieve the list of places that Google has displayed using the Google Places API and then establish your own pins and click events for them?
It's a bit hacky, and doesn't work on IE < 9, but you can listen on dom event,
to detect the creation of the window, using
Mutation Observer
Here is a plunkr to demonstrate : http://plnkr.co/edit/pGep9OZFligLhRtHlhgk
You can check in the console, an event is fired (actually twice) when you click on a POI.
Note that the OP is asking about doing this using the GMAP3 library, which is a jQuery plugin library that adds an API layer on top of the Google Maps layer. it is absolutely correct to say that the Google API is to use google.maps.addListener, but I think that the OP wants something that's closer to the GMAP3 example using addMarkers, but listening to the click event. With that in mind, I modified the example from GMAP3 and changed the mouseenter event to the click event and got rid of the mouseleave event.
Refer

Obtaining latLng of cursor/mouse when triggered by a PolyMouseEvent

I am new to the Google Maps API... so I apologize in advance if the answer to this question is somewhat basic... I have spent several hours trying to find a solution.
Explanation:
I would like to show an infowindow at the point the cursor was at when a click was detected while in a polygon.
I am able to open the infowindow - but am unable to determine the location to use.
It appears that the PolyMouseEvent object does not allow for getting the latLng like the MouseEvent does.
Is there a way to the the current mouse position (in latLng) in this case?
Set clickable:false in the PolygonOptions and listen for the click event on the map itself.

Select position inside Google Maps

I wonder if there is any plugin that lets me do this:
Click on the map, and auto generate the latitude and longitude. I have seen one somewhere, but don't know what library the site is using.
Click on the map, generate closest address. This I haven't seen before.
You can get the position with a simple click listener
google.maps.event.addListener(map, 'click', function(e) {
alert(e.latlng);
});
To get the closest address take a look at reverse Geocoding.
http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
Edit: all of this is included in the basic google maps api :)