kkpowar / gmaps-utility-library-dev

Automatically exported from code.google.com/p/gmaps-utility-library-dev
0 stars 0 forks source link

markerManager incompatible with gmap2 object #104

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. see relevant code below
2. no actions necessary, occurs on page load

What is the expected output? What do you see instead?
Expected Output: none
Acutal Output: breaks map

From Firefox (has same issue in IE, but no useful error message):
Error: d is undefined
Source File: 
http://maps.google.com/intl/en_us/mapfiles/151e/maps2.api/main.js
Line: 551

What version of the product are you using? On what operating system?
Causes the error with both the 1.0 and 1.1 versions of markermanager.js

Please provide any additional information below.

<script src="http://maps.google.com/maps?file=api&v=2&key=%KEY OMITTED%" 
type="text/javascript"></script>
<script src="js/markermanager.js" type="text/javascript"></script>
<script typy="text/javascript">
    function initialize() {
        if (document.getElementById("map_canvas") && GBrowserIsCompatible
()) {
            var map = new GMap2(document.getElementById("map_canvas"));
            var mgr = new MarkerManager(map);
        }
    }
</script>

Original issue reported on code.google.com by rad131...@gmail.com on 20 Apr 2009 at 4:45

GoogleCodeExporter commented 8 years ago
removing var mgr = new MarkerManager(map); eliminates the runtime error

Original comment by rad131...@gmail.com on 20 Apr 2009 at 4:47

GoogleCodeExporter commented 8 years ago
The following code executes sucessfully:

    function initialize() {
        if (document.getElementById("map_canvas") && GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map_canvas"));
            map.disableDragging();
            map.setMapType(G_HYBRID_MAP);

            var address = "Syracuse NY, USA";
            var geocoder = new GClientGeocoder();
            map.setCenter(new GLatLng(37.4419, -122.1419), 13)
            var mkrMgr = new MarkerManager(map, { trackMarkers: true });

            GEvent.addListener(map, "click", function(overlay, latlng) {
                    if (DEBUG == 1) alert("You clicked the map.");
                    mkrMgr.addMarkers(new GMarker(latlng), 16);
                }
            );

        }

    }

The following code fails:
    function initialize() {
        if (document.getElementById("map_canvas") && GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById("map_canvas"));
            map.disableDragging();
            map.setMapType(G_HYBRID_MAP);

            var address = "Syracuse NY, USA";
            var geocoder = new GClientGeocoder();
            geocoder.getLatLng(address, function(point) {if (!point) alert(address 
+ " not found"); else map.setCenter(point, 6);});
            var mkrMgr = new MarkerManager(map, { trackMarkers: true });

            GEvent.addListener(map, "click", function(overlay, latlng) {
                    if (DEBUG == 1) alert("You clicked the map.");
                    mkrMgr.addMarkers(new GMarker(latlng), 16);
                }
            );

        }

    }

The only conclusion that I can come to is that the MarkerManager is envoked 
before 
map.setCenter, causing the error.

This dependency should be listed somewhere in the documentation.

Original comment by rad131...@gmail.com on 20 Apr 2009 at 6:48

GoogleCodeExporter commented 8 years ago
The core Maps API documentation does say that setCenter must always be called 
after 
GMap2; it is an error to do otherwise.
http://code.google.com/apis/maps/documentation/reference.html#GMap2
http://code.google.com/apis/maps/documentation/reference.html#GMap2.setCenter

Original comment by pamela.fox on 20 Apr 2009 at 8:26

GoogleCodeExporter commented 8 years ago
Not all of your documentation is correct:

http://code.google.com/apis/maps/documentation/overlays.html#Marker_Manager

Original comment by rad131...@gmail.com on 21 Apr 2009 at 11:35

GoogleCodeExporter commented 8 years ago
Good point, that will be fixed in next few days.

Original comment by pamela.fox on 23 Apr 2009 at 4:30