Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to get the map to move and zoom in to a point when a function is executed. Point gets selected, but without zoom. Interestingly when I zoom in to a random location and then execute the method I'll get zoomed out a bit and moved to correct position.

drawPointToMap(true);

Code:

function drawPointToMap(zoom) {
var lat = $('#id_latitude').val();
var lon = $('#id_longitude').val();

if (lat != '' && lon != '' && !isNaN(lat) && !isNaN(lon)) {
    try {
        var point = new esri.geometry.Point({
            latitude: lat,
            longitude: lon
        });
        mapHandler.drawToMap(point);
        if (zoom) {
            console.log('center and ZOOM');
            mapHandler.map.centerAndZoom(point, 10);
        } else {
            mapHandler.map.centerAt(point);
        }
    } catch(err) {}
}

}

Console prints 'center and ZOOM' as expected, but doesn't actually zoom. I'm displaying a WMS layer without a basemap.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

I have used similar functionality in my map.

-Created doIdentify() function and called on click event.

function doIdentify(evt) {
         app.map.centerAndZoom(evt.mapPoint,6);
                          }

You can check sample code at JSFiddle.

Please let us know if you get any error message.

share|improve this answer
    
Thank you, your solution works. –  ObviousCat Apr 24 '13 at 19:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.