views:

223

answers:

1

Hello, have created a map that I'm trying to have function similar to 'My Maps'. I have two dropdownlists on the right side, based on the selection in those ddl's, you can add a custom marker / icon. You select a marker type, then click the '+' button in the top right corner of the map, and then click where you want the marker added. My issue is, this works fine in IE, Safari, and Chrome, but not in firefox. The click event doesn't seem to fire.

Here is the location of the map : https://ait.saultcollege.ca/Michael.Armstrong/Index.html

The button to add the marker in the top right has an onclick event pointing to my 'placeMarker()' function. Here is the code for placeMarker(), createMarker() ...

function placeMarker() {

    select("placeMarker");

    var infowindow = new google.maps.InfoWindow({}); 
    var catID = document.getElementById('category');
    var typeID = document.getElementById('ddlType');
    var category = catID.options[catID.selectedIndex].value;
    var markerType = typeID.options[typeID.selectedIndex].value;

    if (!markerType) {
        alert("You must select an icon type.");
    } 
    else {
        var moveListener = google.maps.event.addListener(customMap, 'mousemove', function(event) {
            if (mapMarker) {
                mapMarker.setPosition(event.latLng);
            } else {
                mapMarker = createMarker(event.latLng, "test", markerType, "test");
            }
        });

        var clickListener = google.maps.event.addListener(customMap, 'click', function(event) {
            if (mapMarker) {
                select("hand_b");
                google.maps.event.clearListeners(customMap, 'mousemove');
                google.maps.event.removeListener(listener);
                mapMarker = createMarker(event.latLng, "test2", markerType, "test");

                var htmlInfo = "" +
                    "Category:" + category + "" +
                    "Item:" + markerType + "" +
                    "Notes:" +
                    "Location:" + mapMarker.getPosition().toString() + "" +
                    "" +
                    "";

                //infowindow.setContent(htmlInfo);
                //infowindow.open(customMap, mapMarker);
            }
        });
    }
}

function createMarker(latlng, title, icon, html) {
    var mapMarker = new google.maps.Marker({
        position: latlng,
        map: customMap,
        title: title,
        icon: 'Images/' + icon + '.png'
    });
    return mapMarker;
}

function select(buttonId) {
    document.getElementById("hand_b").className = "unselected";
    document.getElementById("placeMarker").className = "unselected";
    document.getElementById(buttonId).className = "selected";
}

Any help or suggestions would be awesome. Could this perhaps be a bug in ff?