0

I am currently working on modifying the store locator template from MapBox: https://github.com/mapbox/foursquare-store-locator https://www.mapbox.com/blog/foursquare-store-locator/

The problem is in adding a linestring/polyline to this modified framework.

For example, I am not able to add a new map layer with the linestring GeoJSON data using this format:

L.map('map').

I can get the linestring to work with leafllet.js:


http://jsfiddle.net/xpancom/hUy5g/16/


...but this utilizes the "L." from leaflet.js and doesn't work in the modified MapBox template.

L.geoJson(myLine1, {style: myStyle}).addTo(map);

The problem is the modified store locator app from MapBox doesn't appear to implement this same interface.

Here is my current code that attempts to add the layer that has the linestrings:

foursquare.lines = function() {

  var lines = { 'type': 'FeatureCollection',
        'features': []
    };

lines.features.push({
            type: 'Feature',
           // id: venue.id,
            geometry: {
                type: 'LineString',
                coordinates: [[
            60.317769,
            24.929009
          ],
          [
            24.9292486208828,
            60.1681323558666
          ],
          [
            24.951764345169067,
            60.168932342858554
          ],
          [
            24.93321418762207,
            60.16911913731421
          ],
          [
            24.952929,
            60.167312
          ],
          [
            24.944114685058594,
            60.170111798603266
          ],
          [
            24.94499444961548,
            60.171435300334004
          ]]
            },
            properties: {}

        }); //push

//console.log(lines);

if (MM_map.lineLayer) {
        MM_map.lineLayer.geojson(lines);
        alert("hi");
    } else {
        MM_map.lineLayer = mmg().geojson(lines);
        //alert("hello");
        console.log(lines);
    }

 MM_map.addLayer(MM_map.lineLayer);

  }; //foursquare.lines

The layer gets added as an empty div but the geojson and the lines object don't get processed and don't show.

When I run console.log(lines) I get all the geojson data correctly it just doesn't get added using this line:

mmg().geojson(lines)

I really appreaciate any help on this. Thanks

4

1 回答 1

1

Foursquare 商店定位器示例基于 MapBox.js v0.6.7,而您尝试使用 v1.x 及更高版本的代码。您要么需要查阅 v0.6.7 文档,要么从不同的起点开始,这是我推荐的 - 例如,请参阅MapBox.js 示例

于 2013-11-07T22:22:35.370 回答