1
votes

The two functions of relevance are below.

I want to add custom properties to the markers. To be specific, the userID to the properties object. It doesn't have to be there but what i've done below does not work.

Is there no way to pass custom properties?

    initMap:function(){

      L.mapbox.accessToken = 'myToken';
      Shop.el.map = L.mapbox.map('map');
      Shop.el.retailersLayer = L.mapbox.featureLayer().addTo(Shop.el.map);
      Shop.el.retailMarkers = [];

      // add tile layer
      L.tileLayer('myLayerKey', {
          maxZoom: 18
      }).addTo(Shop.el.map);

      // By default, center map over Colorado
      Shop.el.map.setView([39.7392, -104.9847], 12);

     },

    addGeoJSONToMap:function(retailers){

    // format geoJSON
    jQuery.each(retailers, function(index, val) {

      // Push each on of the retail locations into the retailMarkers array
      Shop.el.retailMarkers.push(
            {
                type: 'Feature',
                geometry: {
                    type: 'Point',
                    coordinates: [parseFloat(val.lng), parseFloat(val.lat)]
                },
                properties: {
                    'userId':'99', <------------------------ This does not work. 
                    'marker-color': '#193441',
                    'marker-symbol': 'star-stroked',
                    title: ' val.name,
                    description: 'Marker Description'
                },
            }
      );

    });

    // Add the retail location as markers to the map
    Shop.el.retailersLayer.setGeoJSON({
        type: 'FeatureCollection',
        features: Shop.el.retailMarkers
    });

    },
1

1 Answers

0
votes

Never mind. This DOES work. The property is then found in:

marker.features.userID