I am trying to determine the best way to off center a zoom based on browser window size. I have a div container nested within my map div on the right side which takes up 20% of the screen. I would like to off center the map.centerAt() function 20% to the left to compensate for this taken space. Does anyone have an idea on the best way of going about this? Any suggestions are greatly appreciated. Thanks in advance.
Convert the point you want to center on to a screen point, this will give you the coordinates in pixel space. Then substract/add 0.2*map.width from the X value and convert the point back to map units and use that to center on. Makes sense?
I would like to off center my polygon features the same way. Currently I am using : map.setExtent(polygonFeatureLayer.geometry.getExtent().expand(1.1)); Would I simply do the same for the x coordinate for the polygon and recalculate the extent?
to do what? map.centerAt only works with points...
Thanks, worked perfectly for my point features. Would a similar method be used for polygons?
You can also skip the unit conversion and use 0.2*map.extent.getWidth()...
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.