Basic open info window on map load

3,731 views
Skip to first unread message

Dev Web

unread,
Nov 12, 2010, 8:17:49 AM11/12/10
to google-map...@googlegroups.com
Sorry if this is a bit basic but on V2 there was code for loading a map with no markers and an info window automatically opened containing text or html for the one address you wanted to show, middle of the map.
In V3 I have only found the examples describe a marker exisiting first which when clicked on, opens the infowindow.
Because you can now have many infowinfdows has this basic function been removed?
 
Could anyone kindly provide the code to just open the simple window automatically please.
 
Does this mean if I can do this, I cannot have mulitple windows if I want to place multiple markers on the map at some future occasion, or if I can would there be some simple code to do this please?

geoco...@gmail.com

unread,
Nov 12, 2010, 8:35:46 AM11/12/10
to Google Maps JavaScript API v3
On Nov 12, 5:17 am, Dev Web <adwo...@sensibleweb.co.uk> wrote:
> Sorry if this is a bit basic but on V2 there was code for loading
> a map with no markers and an info window automatically opened
> containing text or html for the one address you wanted to show,
> middle of the map.
> In V3 I have only found the examples describe a marker exisiting
> first which when clicked on, opens the infowindow.

http://code.google.com/apis/maps/documentation/javascript/examples/in...

> Because you can now have many infowinfdows has this basic function
> been removed?

What about this example from the documentation:
http://code.google.com/apis/maps/documentation/javascript/examples/map-coordinates.html

listed on the Samples page:
http://code.google.com/apis/maps/documentation/javascript/examples/index.html

-- Larry

Dev Web

unread,
Nov 12, 2010, 9:47:47 AM11/12/10
to google-map...@googlegroups.com
Thanks Larry.
 
However, the coord and other code in that one is a bit foreign to me.
 
If you look at the example given in V2 it was simple to understand:
 
If the documentation example is the only one that covers this could you please tell me what bits of code relating to the infowindow, I would need in a basic  V3 map below please and the addlistener bit I guess I would need to miss out Eg:
 
<script type="text/javascript">
  function initialize() {
    var myLatlng = new google.maps.LatLng(TEST, CO-ORDS);
    var myOptions = {
      zoom: 10,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.HYBRID
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
     var contentString = '<div id="content">'+
        '<p><b>Test Example</p> '+
        '</div>';
       
    var infowindow = new google.maps.InfoWindow({
        content: contentString
    });
 
    var marker = new google.maps.Marker({
        position: myLatlng,
        map: map,
        title: 'Example Name'
    });
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
 }
 
  function loadScript() {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src = "http://maps.google.com/maps/api/js?v=3&sensor=false&region=FR&callback=initialize";
    document.body.appendChild(script);
  }
 
  window.onload = loadScript;
</script>
Thanks
 

geoco...@gmail.com

unread,
Nov 12, 2010, 9:53:53 AM11/12/10
to Google Maps JavaScript API v3
On Nov 12, 6:47 am, Dev Web <adwo...@sensibleweb.co.uk> wrote:
> Thanks Larry.
>
> However, the coord and other code in that one is a bit foreign to
> me.

Then take it out.

>
> If you look at the example given in V2 it was simple to understand:http://code.google.com/apis/maps/documentation/javascript/v2/introduc...
>
> If the documentation example is the only one that covers this
> could you please tell me what bits of code relating to the
> infowindow, I would need in a basic V3 map below please and the
> addlistener bit I guess I would need to miss out

I think an example of this has been posted to the group in the past,
did you try searching?

I don't have time right now to search for you or put together a simple
example, but when time permits I will (unless someone beats me to
it...)

-- Larry
> = "http://maps.google.com/maps/api/js?v=3&sensor=false®ion=FR&callbac...";

Dev Web

unread,
Nov 12, 2010, 10:06:39 AM11/12/10
to google-map...@googlegroups.com
Sorry Larry, bearing in mind the example code I used from above and built from the basic examples I am working with, the example you quoted bears little resemblance to it. I do understand you are busy and thanks for pointing me to it anyway.
 
I have searched on a few occasions and not found one although I am not suprised it has been requested before.
 
I would have thought it would have been the first example going, like it was in V2.
 
If any kind coding person is able to do this, I would be very grateful and maybe so will others looking for a simple map and one place infowindow that opens on pageload..
 
Thanks
 

geoco...@gmail.com

unread,
Nov 12, 2010, 10:53:45 AM11/12/10
to Google Maps JavaScript API v3

Dev Web

unread,
Nov 12, 2010, 12:51:01 PM11/12/10
to google-map...@googlegroups.com
Thank you very much Larry - that is just what I wanted.
 
I really could not find it in the search.
 
Reckon it would make a great first simple example to place on the examples/demo page.

geoco...@gmail.com

unread,
Nov 12, 2010, 2:49:07 PM11/12/10
to Google Maps JavaScript API v3
On Nov 12, 9:51 am, Dev Web <adwo...@sensibleweb.co.uk> wrote:
> Thank you very much Larry - that is just what I wanted.
>
> I really could not find it in the search.

It took me a little searching. I thought I remembered the request for
the "hello world" example and putting it together, but look at the
search terms I used to find it:
"geocodezip infowindow on map"
>
> Reckon it would make a great first simple example to place on the
> examples/demo page.

Maybe Luke or Chad or one of the Google engineers will see this thread
and make an example like that.
(you could create an issue if you feel strongly)

-- Larry

realalien

unread,
Nov 21, 2010, 4:00:18 AM11/21/10
to Google Maps JavaScript API v3
Thanks for the example, this thread is my first web search result for
similar simple question.

Finally, I found that passing event.latLng to InfoWindowOptions's
position without calling toString(), the infoWindow won't come out!

Why such weak-typed language enforced me to call toString(), what's
the purpose of API designer's intention?


On Nov 13, 3:49 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:

Shreerang Patwardhan

unread,
Nov 21, 2010, 9:33:47 PM11/21/10
to google-map...@googlegroups.com
There is one such example at http://shreerangpatwardhan.blogspot.com/2010/11/only-information-bubbles.html and also at http://shreerangpatwardhan.blogspot.com/2010/11/static-info-window-only.html.


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.




--
Regards,
Shreerang Patwardhan.
Trainee Developer
DSK Digital Technologies Pvt. Ltd.
LinkedIn Profile
https://sites.google.com/site/shreerangmohanpatwardhan/


Reply all
Reply to author
Forward
0 new messages