0

I'm working on a school project and I'm trying to create a world map with only airport locations (and their corresponding long and lat value).

I had to create a database for it, and used a sql statement (part of the assignment. Now I'm able to see the the positive value of the long and lat I think: http://webpages.avans.nl/acue-gast01/database/index.html

However, I have no clue how show the negative values of both the alt and long... and how I can fit them on the screen.

This is what I have

$.getJSON("index.php", function(data) {
// show data in console
console.log(data);

$.each(data, function(key, val) {
    // show data per item in console
    console.log(key + " - " + "Longitude" + ": " + val.Airport_LONG + " | " + "Latitude" + ": " + val.Airport_LAT);

$("<div>").html(val.Airport_LAT, val.Airport_LONG)
    .css('background-color','white')
    .css('left',val.Airport_LONG/10*380 + "px")
    .css('top',val.Airport_LAT/10*380+"px")
    .css('margin','20px')
    .css('width','20px')
    .appendTo("body");
});
});

Does anyone have a idea?

Jongware
  • 22,200
  • 8
  • 54
  • 100
  • 2
    You should put the center of your map in 0,0 in order to leave some room for the negative coordinates. – Mehdi Dec 28 '14 at 11:56
  • Victor, welcome to Stackoverflow. I find your question quiet unclear: if you have a concerete technical question like _doing this, expeceted this, but got this_ or _want to do this, how to achieve_ you're right here but you should provide more details (which technology you use, code you have so far). If your question is general like _how to approach this_, you should ask at http://programmers.stackexchange.com – try-catch-finally Dec 28 '14 at 11:58
  • I'm very sorry, I added the code I thought.. very sloppy of me. here it is :) – Victor Roos Dec 28 '14 at 12:26
  • and, what do you mean with center the map?.. – Victor Roos Dec 28 '14 at 12:26
  • 1
    The latitude for everything east of Greenwich is positive, but for airports west of it is negative. New York, for example, is at -74 deg. Since you are plotting "from the left", all negative values fall out of the screen. Add a constant to 'move' everything to the right. (1) Which constant? Think: what is the min value ;) (2) Change your scale so everything still fits; (3) Same for longitude, although the constant is different. – Jongware Dec 28 '14 at 12:34
  • possible duplicate of [Convert Lat/Longs to X/Y Co-ordinates](http://stackoverflow.com/questions/1019997/convert-lat-longs-to-x-y-co-ordinates) – Jongware Dec 28 '14 at 12:46

1 Answers1

1

Currently your origin point (0,0) is the top-left corner of the screen. Anything with a negative coordinate will be off to the left or top and unreachable.

You can somewhat fix this issue by doing something like (val.Airport_LONG/10*380 + 500) to shift the origin point and allow them to appear, but the best solution may be to find the minimum and maximum coordinate and use these to shift and scale the entire map.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • hm, shift and scale, so that would fix the weird way it is bown now? And I don't understand the minimum and maximum part?.. – Victor Roos Dec 28 '14 at 13:22
  • @VictorRoos: if you want to do it yourself, ask yourself, "what are the numerical limits of the Long/Lat notation?" If not: see http://stackoverflow.com/questions/1019997/convert-lat-longs-to-x-y-co-ordinates – Jongware Dec 28 '14 at 13:39