Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
gregiee
gregiee's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
interactive map problems
[1 Reply]
17-Jan-2013 11:38 AM
Forum:
Programming Questions
Hi,
i just leaned how to use this, and was trying to create a map which shows my friends current location.
obviously it's not a easy job.....
how can i
create a mouse event: when mouseover the dot, my friends name shows up somewhere.
to draw lines between the dots and mouse.
i tried:
line(p.x,p.y,mouseX,mouseY);
but it didn't really work.
here is the code of the sketch:
PImage backgroundMap;
float mapGeoLeft = -100; // Longitude 125 degrees west
float mapGeoRight = 153.44; // Longitude 153 degrees east
float mapGeoTop = 71.89; // Latitude 72 degrees north.
float mapGeoBottom = -80; // Latitude 56 degrees south.
float mapScreenWidth,mapScreenHeight; // Dimension of map in pixels.
void setup()
{
size(600,350);
textSize(10);
smooth();
noLoop();
backgroundMap = loadImage("world.jpg");
mapScreenWidth = width;
mapScreenHeight = height;
}
void draw()
{
image(backgroundMap,0,0,mapScreenWidth,mapScreenHeight);
stroke(204, 102, 0);
fill(255, 150);
strokeWeight(1);
PVector
p = geoToPixel(new PVector(0.8,51.5));
ellipse(p.x,p.y,5,5);
p = geoToPixel(new PVector(-82.0,39.5));
ellipse(p.x,p.y,5,5);
}
public PVector geoToPixel(PVector geoLocation)
{
return new PVector(mapScreenWidth*(geoLocation.x-mapGeoLeft)/(mapGeoRight-mapGeoLeft),
mapScreenHeight - mapScreenHeight*(geoLocation.y-mapGeoBottom)/(mapGeoTop-mapGeoBottom));
}
can anyone give some instruction plz
thx!!
greg.
«Prev
Next »
Moderate user : gregiee
Forum