last day (15 days later) » 

7:28 PM
0
A: Markers not plotting on map using Mapbox and leaflet?

iH8You're not adding your L.mapbox.featureLayer (pivotslayer) to you mapinstance: var pivotsLayer = L.mapbox.featureLayer(); Assuming you have a reference to your map instance in a variable called map: var pivotsLayer = L.mapbox.featureLayer().addTo(map); // or map.addLayer(pivotsLayer);

 
I tried. Still doesn't work. In fact I tried plotting the markers straight to the map itself. Still won't work. And I also tried plotting a marker outside the loop to test just to have a look. Do you want me to post the whole code?
 
iH8
If you could, including some test data, would be nice. Creating a Plunker which demonstrates your problem is even beter, here's a boilerplate: plnkr.co/edit/VjijEh?p=info
 
Like the object that returns from the server. If you want I can copy and post it in the question?
 
iH8
Yup. The data that get's returned from $.getJSON and the rest of the code including your map etc.
 
I am trying to plot a circle now instead of a marker. Just letting you know.
The data returned from the server has only one pivot right now, but the code should work for any number, other than the fact that it doesn't right now because the circle is not being plotted.
 
iH8
7:28 PM
That's too comprehensive to make a normal testcase of. Do you get any errors in your console? Do the companies and farms get plotted? This must be a very simple problem which is easy to debug if you just strip down your code to the bare minimum.
 
I tried that. The thing is everything is getting plotted and the cirlces are also initializing because I console log them to and now I can plot circles out of the loop. Just inside the loop it is giving me a problem. I don't know why.
I have two errors in my console but they have been since I started working like they are coming from some other code.
Using //@ to indicate sourceMappingURL pragmas is deprecated. Use //# instead jquery.min.js:1
Use of getPreventDefault() is deprecated. Use defaultPrevented instead. jquery.min.js:5
Object { id: "4", farm_id: "101", distributor_id: "2", lat: "-68.51074219", long: "-28.93124697", radius: "10000.00", brand: "Valley", model: "8000", coa: "8 5/8", coa_model: "Flexible", 49 moreā€¦ } equipment-map:687
Object { options: Object, _latlng: Object, _mRadius: 10000, _initHooksCalled: true, _leaflet_id: 41, _leaflet_events: Object, _map: Object, _container: <g>, _path: <path.leaflet-clickable>, _point:
This is the copy paste of my console.
 
7:46 PM
circle_coords = [parseFloat(pivot_item.lat), parseFloat(pivot_item.long)];
circle_radius = parseFloat(pivot_item.raduis);
console.log(circle_coords);
var circle = L.circle(circle_coords, circle_radius).addTo(map);
I tried this inside in the loop
Error: Invalid LatLng object: (-68.51074219, NaN) mapbox.js:1
Array [ -68.51074219, -28.93124697 ]
And I get this in the console.log. Any idea?
 
iH8
hmmm. looks like there is something wrong with your longitude
lemme check
hold on
here's a typo: ircle_radius = parseFloat(pivot_item.raduis); but that's got nothing to do with longitude
raduis != radius
 
I corrected that
Still won't work
is long reserved or something?
 
iH8
It's future reserved for old ECMA but that shouldnt be a problem
 
I logged the circle after plotting and it showing the lat long correctly.
 
iH8
Works for me as a single circle
really baffled, and i haven't got much time at the moment to look in to it
i'll reread you code asap
*your
 
8:01 PM
Thank you for your time anyway. You are really helpful
 
iH8
Can't you show me your project online somewhere, that would be much much quicker to debug
 
I will push the code to the serve and then give you the credentials. Do you want me to do it right now?
 
iH8
ok, that would be great, i'll take a look when you give them to me
 
julienbaudet@sigagro.com
password
Tell me if you have any issues with logging in?
 
iH8
i'm in, i'll take a look
 
8:12 PM
I know you logged in. Thanks for the help. I owe you.
Click on the territroy on the top
And then the farm on the top again
That is where the circle should come up
 
iH8
Problem solved ;)
 
Really>
What was it?
 
iH8
You've mixed up your lat/lng
 
I bet it was something stupid opn my part
 
iH8
Try var circle_coords = [parseFloat(item.long), parseFloat(item.lat)];
 
8:16 PM
Oh maaaana
 
iH8
lol
 
Is that what I did
 
iH8
yeah but it's in your data
 
Excuse me for a second. I must bang my head against the wall a few times before I continute.
 
iH8
hahahahahaha
 
8:17 PM
continue*
 
iH8
glad it's solved ;)
 
Thank you so much
I really owe you.
 
iH8
no problem :) glad to help
 
Wait, ill accept and upvote. Edit the answer though!
 
iH8
yup i will, in a few minutes
 
8:20 PM
Thank you yet again.
 
iH8
:)
 

last day (15 days later) »