Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
112
rated 0 times [  115] [ 3]  / answers: 1 / hits: 19482  / 11 Years ago, wed, february 27, 2013, 12:00:00

I have a problem about gmaps v0.3 that when I addMarker How let infoWindow auto open. not when you onclick open.



<script type=text/javascript>
var map;
$(document).ready(function(){
map = new GMaps({
div: '#map',
lat: 39.908403,
lng: 116.397529,
zoom: 1,
});
var marker = new google.maps.Marker();
marker = {
lat: 39.908403,
lng: 116.397529,
title: 'Lima',
//map: map.map,
//animation: google.maps.Animation.BOUNCE,
//shape: {coords: [0,0,50,50], type: rect},
infoWindow: {
content: '<font color=red>hello world</font>'
}
}
map.addMarker(marker);
});




I want to when addMarker auto open infoWindow not click, what should I do.
please help me.


More From » jquery

 Answers
21

You can open the infoWindow by using the .open function:



// Create map
var map = new GMaps({
div: '#map',
lat: 39.908403,
lng: 116.397529,
zoom: 1,
});

// Create infoWindow
var infoWindow = new google.maps.InfoWindow({
content: 'Content goes here..'
});

// Create marker
var marker = new google.maps.Marker({
lat: lat,
lng: lng,
title: 'Lima',
map: map.map,
infoWindow: infoWindow
});

// This opens the infoWindow
infoWindow.open(map, marker);


You can read about infoWindow at the Google Maps website https://developers.google.com/maps/documentation/javascript/overlays#InfoWindows


[#79970] Tuesday, February 26, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dexter

Total Points: 717
Total Questions: 98
Total Answers: 115

Location: Sudan
Member since Thu, May 7, 2020
4 Years ago
;