This is a migrated thread and some comments may be shown as answers.

Dynamic Map Shape Problem

1 Answer 63 Views
Map
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 17 Jul 2015, 04:06 PM

I'm having trouble adding shapes to my map.

Here's my shape layer definition:

{
                type: "shape",
                style: {
                    stroke: {
                        color: "blue",
                        width: 4,
                        dashType: "solid",
                        opacity: 0.5
                    }
                },
                dataSource: shapes
            }

And this is how I'm adding things to it:

shapes.add({ "id": "FRA", "type": "Feature", "geometry": {
            "type": "MultiLineString",
            "coordinates": [myList] }
        });

When I hardcode the populating of myList using numbers I found in another thread on shapes it works:

var myList = [];
 
var pos = myList.length;
myList[pos] = [];
myList[pos][0] = -9.10531212;//I put these in here to make sure the problem wasn't that my coordinates were too precise.
myList[pos][1] = 43.91251212;
pos = myList.length;
myList[pos] = [];
myList[pos][0] = 3;
myList[pos][1] = 43;
pos = myList.length;
myList[pos] = [];
myList[pos][0] = 2;
myList[pos][1] = 36;
pos = myList.length;
myList[pos] = [];
myList[pos][0] = -9;
myList[pos][1] = 37;

But when I try to use the numbers from my data it doesn't work:  

var pos = myList.length;
        myList[pos] = [];
        myList[pos][0] = 42.3055286;
        myList[pos][1] = -87.89389;
        pos = myList.length;
        myList[pos] = [];
        myList[pos][0] = 42.3055415;
        myList[pos][1] = -87.8938938;
        pos = myList.length;
        myList[pos] = [];
        myList[pos][0] = 42.3055766;
        myList[pos][1] = -87.8938775;
        pos = myList.length;
        myList[pos] = [];
        myList[pos][0] = 42.3055958;
        myList[pos][1] = -87.8938808;

It looks like it should work to me, but it's not.  It never draws the line when I use my own data.

 Any ideas?

 

1 Answer, 1 is accepted

Sort by
0
Matt
Top achievements
Rank 1
answered on 17 Jul 2015, 04:27 PM
I figured it out.  I expected the coordinates to be in the format [Latitude, Longitude], but actually they need to be in the opposite order [Longitude, Latitude].
Tags
Map
Asked by
Matt
Top achievements
Rank 1
Answers by
Matt
Top achievements
Rank 1
Share this question
or