angular-ui / ui-leaflet

AngularJS directive to embed an interact with maps managed by Leaflet library
http://angular-ui.github.io/ui-leaflet
Other
315 stars 137 forks source link

How to build a map with the array of values using leaflet directive #124

Open nmccready opened 8 years ago

nmccready commented 8 years ago

From @balajijana on October 5, 2015 13:14

Hi,

I am a new beginner in learning the leaflet directive.I have latitude and longitude in an array for 4 locations. For each location i need to display a map with by passing the latitude and longitude. Below is my code:

angular.forEach($scope.activities, function (activities, index) {          
            if (activities._id) {
              actId.push(activities._id);
              latid = activities['attributes'].loc[0][0];
              longid = activities['attributes'].loc[0][1];
              txt = activities.text;
               // console.log(latid); 
                //console.log(longid);
               // console.log(txt);
               $scope.osloCenter = {
                  lat: latid,
                  lng: longid,
                  zoom: 22
                };
                $scope.markers = {
                  osloMarker: {
                    lat: latid,
                    lng: longid,
                    message: txt,
                    focus: true,
                    draggable: false
                  }
                };
            }           
          });

When i print the value in the console i am able to get the array values for 4 locations as an array. I need to know how to pass the array values to iterate it to display the map for each location. Also I am getting the following error:

[AngularJS - Leaflet] The marker definition is not valid. angular.js:11655 [AngularJS - Leaflet] [AngularJS - Leaflet] Received invalid data on the marker osloMarker.

Please help me out what is this error and how to rectify it or any other alternative solutions

Copied from original issue: tombatossals/angular-leaflet-directive#972

nmccready commented 8 years ago

From @chidg on October 26, 2015 6:4

Check that your lat and lng values passed to the marker are floats.

nmccready commented 8 years ago

881