Reputation: 5
I've included a google map on my webpage with a marker at the location. What I want to add is an existing infoWindow of that location when the page loads. This is the code i have:
<script>
function initialize() {
var mapCanvas = document.getElementById('map-canvas');
var mapOptions = {
center: new google.maps.LatLng(51.257195, 3.716563),
zoom: 10,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions);
new google.maps.Marker({
position: new google.maps.LatLng(51.257195, 3.716563),
map: map
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
screenshot: http://puu.sh/gMtoB/16312f42b7.jpg
Now the "AXA..." is an existing point of interest on google maps, how would i go about that my marker is actually 'linked' to that existing point of interest with the infowindow opened by default.
in short: i would like a marker on that location with the infowindow opened when the webpage loads.
Upvotes: 0
Views: 50
Reputation: 4784
I think the solution would be to first find the place_id
and then add your marker using the place ID you found rather than using longitude and latitude.
I created a live demo here: https://jsfiddle.net/qzo41qzd/
There is also an example in the documentation about placing a marker on the google map using place_id
:
https://developers.google.com/maps/documentation/javascript/places#placeid
Upvotes: 1