When I click on a feature in my map, I display a large popup. When the popup is displayed, the map is moved to the side so that the feature is visible as well as the large popup in its entirety. When the popup is closed, the map stays in place, with the feature shifted to the side. However, I would like the map to return to the original state before the popup was clicked. I tried saving the Map1.CurrentExtent in my Map1_Click function and reverting back to that after the popup is closed, but it doesn’t appear that the Map1.CurrentExtent is updated correctly if the user has been panning in the map view. Do you have any thoughts on how to achieve this? Thanks, Treasa.
Return to Current Extent After Popup Closed
Hi Treasa,
I think we can try to solve that follow 2 ways.
1. In our OnMapCreating and OnMapCreated function, you can override some Openlayers class, so that you should can find a way to save extent when user click on popup.
2. Save the extent on server side, when you click on map, make sure whether that click on marker, then save the extent, when you close popup, move map back.
In fact I am not sure how to implement them now, that’s just a thought.
And please let me know how you add the popup, so I can try to help you find whether we have some API can be used for this scenario.
Regards,
Don
Hi, I am ready to tackle this issue again, and I’m hoping you can help me.
When I start my web app, say I set the Current Extent to:
Map1.CurrentExtent = new RectangleShape(-76.9784413333333,40.7414781666667,-74.1502681666667,38.9164263333333);
When I click on the Map, in the Map1_Click function, the first thing I do is read the current extent (in case I am going to save it). However, it is reading:
Map1.CurrentExtent = {-77.443016859375,41.229709085938,-73.685692640625,38.428195414063}
Do you know why is it different?
Thanks,
Treasa
Hi Treasa,
The -76.9784413333333,40.7414781666667,-74.1502681666667,38.9164263333333 is your initialization sample, when it render in client side, we will recalculate the new extent for make the map render better.
So you won’t get the same extent like your initialization.
If you want to use the initialization value, please save it in session or viewstate.
Regards,
Don
OK, so when I first initialize my map at:
Map1.CurrentExtent = new RectangleShape(-77.443016859375, 41.229709085938, -73.685692640625, 38.428195414063);
I see Map1Initialize.png:
When I click on the Map, I reinitialize to the same extent, but then my map view changes to the Map1Click.png:
Why does setting the map extent in 2 different places result in 2 different views?
Hi Treasa,
I tested your extent but hadn’t reproduced your issue this time, I think that should related with some client side parameter etc.
Because our map have snap feature, sometimes it will automatic adjust the zoomlevel if the scale value between two levels.
If you keep met that issue, I think you can set Map1.CurrentScale and Map1.CenterAt(centerPoint) to make the map keep shows same extent.
Regards,
Don
Hi Don,
Using CurrentScale and CurrentExtent.CenterPoint works much better than just using CurrentExtent.
Appreciate your insight into getting this working for me.
Treasa
Treasa,
Great to hear Don’s suggestion works for you.
Thanks,
Troy