6

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.

1 Answer 1

7

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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