Please post a link to your site. Looking at code in the group
interface makes me go cross-eyed. I also can't use any handy debugging
tools . . .

If I had to guess to your problem though, with the map as a global
variable the constructor is trying to create the map before the DOM
node is ready so it can't be accessed yet.

Chad Killingsworth

On Mar 21, 6:02 pm, Erwin Dicker <[email protected]> wrote:
> well i'm doing something wrong..
>
> i traid to make this a global variable: var map = new
> google.maps.Map(document.getElementById("map_canvas"),
>
> if i don't put that line in the
> google.maps.event.addDomListener(bermudaTriangle, 'click', function()
> {
> i get a error...
>
> what happend when i click on the polygoon it make's a new map...
> what i wanna do is... click polygoon it goes away and you get the
> other polygoon...
> the final version is.. when you zoom in the redpolygoon goes away and
> you get the yello polygoon
>
> <script type="text/javascript">
>     var myLatLng = new google.maps.LatLng(24.886436490787712,
> -70.2685546875);
>     var myOptions = {
>       zoom: 5,
>       center: myLatLng,
>       mapTypeId: google.maps.MapTypeId.ROADMAP
>     };
>
>     var map;
>     var bermudaTriangle;
>
>     var bb2 = new google.maps.LatLng(22.886436490787712,
> -68.2685546875);
>
>     var triangleCoords = [
>         new google.maps.LatLng(25.774252, -80.190262),
>         new google.maps.LatLng(18.466465, -66.118292),
>         new google.maps.LatLng(32.321384, -64.75737),
>         new google.maps.LatLng(25.774252, -80.190262)
>     ];
>
>     // Construct the polygon
>     bermudaTriangle = new google.maps.Polygon({
>       paths: triangleCoords,
>       strokeColor: "#FF0000",
>       strokeOpacity: 0.8,
>       strokeWeight: 2,
>       fillColor: "#FF0000",
>       fillOpacity: 0.35
>     });
>
> google.maps.event.addDomListener(bermudaTriangle, 'click', function()
> {
>
> // if i don't do this i get a error :S i have to make a new map :s...
> some how it won't get the info out of var
> //
>     var map = new
> google.maps.Map(document.getElementById("map_canvas"),
>         myOptions);
>
>     var triangleCoords = [
>         new google.maps.LatLng(22.774252, -78.190262),
>         new google.maps.LatLng(16.466465, -64.118292),
>         new google.maps.LatLng(30.321384, -62.75737),
>         new google.maps.LatLng(22.774252, -78.190262)
>     ];
>
>     // Construct the polygon
>     bermudaTriangle = new google.maps.Polygon({
>       paths: triangleCoords,
>       strokeColor: "#FFFF00",
>       strokeOpacity: 0.8,
>       strokeWeight: 2,
>       fillColor: "#FFFF00",
>       fillOpacity: 0.35
>     });
>
> //here i get the error when i don't put google.maps.map in it
>    bermudaTriangle.setMap(map);
>   map.setCenter(bb2)
>
> });
>
>   function initialize() {
>
>     var map = new
> google.maps.Map(document.getElementById("map_canvas"),
>         myOptions);
>
>    bermudaTriangle.setMap(map);
>   }
>
> </script>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to