Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

center position is displayed at top left corner in ionic modals #1599

Closed
andreasmaier opened this issue Nov 3, 2015 · 2 comments
Closed

Comments

@andreasmaier
Copy link

Hey, I ran into an issue where angular-google-maps would not display maps correctly in ionic modals.

I created a little sample repo to describe and reproduce this issue. It basically has a tab with a google map that on load displays the map centered correctly. It also provides a possibility to show a modal overlaid on the same page which has the same map, but moves the same center/location to the top left.

The app basically just consists of one tab whose controller is serving the static centerlocation to both the map on the tab view and the modal. Does anybody have an idea what could create this behavior?

controller

angular.module('starter').controller('ModalTabCtrl', function ($ionicModal, $scope) {
    ...
    $scope.map = {
        center: {
            latitude: 37.778414,
            longitude: -122.389212
        },
        zoom: 8
    };
});

tab

<ion-view view-title="Tab">
    <ion-content class="padding">
        <ui-gmap-google-map center='map.center' zoom='map.zoom'>
        </ui-gmap-google-map>
    </ion-content>
    ...
</ion-view>

modal

<ion-modal-view>
    ...
    <ion-content>
        <ui-gmap-google-map center='map.center' zoom='map.zoom'>
        </ui-gmap-google-map>
    </ion-content>
</ion-modal-view>

Here are two images showcasing the shift of the center:

map centered correct

map center on top left

@nmccready
Copy link
Contributor

See #1395 , probably same issue.

@andreasmaier
Copy link
Author

Ok got it. I updated the code to use a control and refresh it when the modal gets shown. This works so far for me and was totally already in the api doc.

    $scope.openModal = function () {
        $scope.modal.show();
        $scope.modalControl.refresh({
            latitude: 37.778414,
            longitude: -122.389212
        });
    };

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants