Mapquest providedLocation

218 views Asked by At

I have a problem with Mapquest. Everything was working just fine until I noticed markers are not showing up on my maps. I didn't change any code, and the mapquest api documentation doesn't seem to have been updated.

Basically, I make a geocoding call and process the json response. I pass in data that is needed for the callback function to properly place markers on a google map.

function addMarker(street_address,city,state,company_name,ri){
        var safe_name = company_name.replace("'","\'");
        safe_name = safe_name.replace("&", "%26");
        var new_index = ri + 1;

        var api_url = "http://open.mapquestapi.com/geocoding/v1/address?key=MY_KEY&location=" + street_address + " " + city + ", " + state + "&name=" + safe_name + "&record_index=" + new_index + "&callback=renderGeocode";
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = api_url;
        document.body.appendChild(script);
    }

    function renderGeocode(response) {
        var location = response.results[0].locations[0];
        var address = response.results[0].providedLocation.location;
        var lat = location.latLng.lat;
        var lng = location.latLng.lng;
        var latlng = new google.maps.LatLng(lat, lng);
        var map_icon = iconBase + record_index + ".png";
        var name = response.results[0].providedLocation.name;
        var record_index = response.results[0].providedLocation.record_index;

        var marker = new google.maps.Marker({
            map: map,
            position: latlng,
            icon: map_icon
        });

        google.maps.event.addListener(marker, 'click', function() {
            window.location = "/yellow_pages/get-directions.aspx?address=" + address + "&co=" + name_for_marker + "&searchtext=<%=Server.UrlEncode(searchtext)%>&location=<%=location%>";
        })
    }

Before Mapquest made their changes,

var name = response.results[0].providedLocation.name;
        var record_index = response.results[0].providedLocation.record_index;

would both return the values I passed to mapquest. This is no longer the case? Has anyone had a similair issue? Like I said, the documentation on mapquest is either out of date, or I'm a big dummy.

0

There are 0 answers