2
votes

I have this geojson

{
   "type":"FeatureCollection",
   "features":[
      {
         "type":"Feature",
         "geometry":{
            "type":"Point",
            "coordinates":[
               -75.70439994335175,
               4.72285137053331
            ]
         },
         "properties":{
            "category":"pajaros",
            "icon":{
               "iconUrl":"http:\/\/tupale.co\/milfs\/images\/secure\/?file=150\/b93a3b673df42a1eb5ca85ffcfa21389.jpg\u002674",
               "iconSize":[
                  60
               ]
            },

            "563":"",
            "564":"b93a3b673df42a1eb5ca85ffcfa21389.jpg",
            "567":"-75.70439994335175 4.72285137053331 18",
            "title":"Semillero andino ( hembra )",
            "566":"Semillero andino ( hembra )",
            "localizacion":"-75.70439994335175 4.72285137053331 18 ",
            "description":"Contenido del json",
            "control":"024a69ad3b495e5c323402211bc7aa97",
            "latLng":[
               -75.70439994335175,
               4.72285137053331
            ],
            "time":1467590201,
            "name":1480263964
         }
      }
   ]
} 

And this function

        /**
         * This is where your '.addLayer()' used to be, instead
         * add only the source without styling a layer
         */
        map.addSource('places', {
          'type': 'geojson',
        //  'data': stores
          'data': 'http://localhost/tupali/cache/45.json'
        });
        map.addLayer({
        'id': 'points',
        'type': 'symbol',
        'source': 'places',
        'layout': {
        // get the icon name from the source's "icon" property
        // concatenate the name to get an icon from the style's sprite sheet
        'icon-image': ['concat', ['get', 'iconUrl'], '-15'],
        // get the title name from the source's "title" property
        'text-field': ['get', 'title'],
        'text-font': ['Open Sans Semibold', 'Arial Unicode MS Bold'],
        'text-offset': [0, 0.6],
        'text-anchor': 'top'
        }
        });

      });

How i can get the iconUrl and icon size from geojson ? i try " 'icon-image': ['concat', ['get', 'icon'], '-15']," but get any array and I don't how explode it. " Image "{"iconUrl":"http://localhost//tupali/milfs/images/secure/?file=150/e1b0013409d0ed4a67c292999928c295.jpg&74","iconSize":[60]}" could not be loaded. "

1

1 Answers

3
votes

Mapbox-GL-JS can't load images by URL in this way. You need to first add the images you need, using map.loadImage() and map.addImage().

https://docs.mapbox.com/mapbox-gl-js/api/#map#loadimage