views:

488

answers:

1

I've been fighting with this for a while, so I think it's better to ask the big guys.

I have the following function which I use to creage GMarkers with some information

 function createMarker(data, html) {
        var marker = new GMarker(new GLatLng(data.latlng.y, data.latlng.x));
        var html = "Provider: "+ data.name.data + "<br/>" +
                   "Address: " + data.address.data + "<br/>" +
                   "Phone: " + data.phone.data + "<br/>" + 
                   '<a href="javascript:zoomit(' + data.latlng.y + ',' + data.latlng.x + ')">Zoom<\/a>';
        GEvent.addListener(marker, 'click', function() {
            marker.openInfoWindowHtml(html);
        });
        return marker;
    }

As you can see, I have a link in the info window to zoom the map, and this is the part I'm having problems now. I want to zoom the map to a specific zoom level when the user clicks on that link.

Any Ideas?

A: 

I do this on my mapping project site. I have some javascript to do the fixed zoom:

function centerAndZoom (CenterLat, CenterLng)
{
    var CenterPoint = new GLatLng (CenterLat, CenterLng);
    map.setCenter(CenterPoint);
    map.setZoom (9);
}

I handle the onClick event for the image in the info window:

html += '<img height="24" onClick="centerAndZoom('+lat+','+lng+')" 
        style="cursor: pointer" src="pics/magnify_glass_small.png">'
Cannonade
Tried, you can take a loot at http://jsbin.com/oqeje, missing something yet, and I think it's a silly thing. Some extra eyes would be helpful :)
Anwar Pinto
Getting a JavaScript (Error: zoomit is not defined). Try moving your definition above createMarker().
Cannonade
Looks like it's looking the function on another document. FireBug shows1 function onclick(event) {2 zoomit(35.525402, -108.735738);3 }any ideas?
Anwar Pinto
Move your zoomit function up and outside the initialize function. http://www.cannonade.net/geo.php?test=geo14
Cannonade