procterw / ng-maps

A Google Maps directive for data intensive AngularJS apps
6 stars 4 forks source link

Is there a way to add just text labels with more than one character? #11

Closed RosanaRufer closed 8 years ago

RosanaRufer commented 8 years ago

I need something like this image

procterw commented 8 years ago

It doesn't look like there's any way to do that with the standard Google maps library, but that would be a useful feature. I'll try to add that over the next day or two. Thanks!

procterw commented 8 years ago

Hey,

I just added a textLabel directive. It renders text centered at a given pair of coordinates. You can also set the directive's class and the text will inherit that class. Give it a shot and let me know if there are any issues. I'll test it more and add documentation later. For now:

In the controller:

$scope.text = {
  features: [
    { text: "text1", coords: [39, -121] },
    { text: "text2", coords: [39.5, -121] }
  ],
  visible: true,
  events: {
    click: function(event, feature, map, features) {
      // Whatever
    }
  }
};

In the HTML:

<text-labels features="text.features" events="text.events" class="text-label"></text-labels>

Then style .text-label however you want in CSS. Currently the directive only has those three attributes, features, visible, and events.

Here's a screenshot:

Image of textLabels

RosanaRufer commented 8 years ago

You rock :metal: I'm now trying it out

RosanaRufer commented 8 years ago

It works perfectly, thank you so much, this issue can be closed.

procterw commented 8 years ago

Awesome! Thanks for bringing that to my attention :)