Skip to content

When adding new markers dynamically, all existing markers lose their labels #46

@style-x7

Description

@style-x7

Hi @tombatossals,

Using static image map, I managed to add marker at the point clicked on the map. However, the existing label message of the existing markers will teleport to the top left of the map.

Looking at the webpage source code, the "popup-label marker ng-binding" of the existing markers are outside of the "ol-viewport", only the "popup-label marker ng-binding" of the newly added marker is inside the "ol-viewport".

Code snippet (html):

<openlayers ol-center="center" ol-markers="markers" height="400px" width="100%">
    <ol-layer ol-layer-properties="staticlayer"></ol-layer>
    <ol-marker ng-repeat="marker in markers" ol-marker-properties="marker"></ol-marker>
</openlayers>

Code snippet (js):

  $scope.$on('openlayers.map.singleclick', function(event, coordinate) {
      $scope.$apply(function() {
        $scope.markers.push({
          coord: coordinate.coord,
          projection: 'pixel',
          label: {
              message: "asd",
              show: true          
          }
        });
      });
  });

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions