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.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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