interactive map problems
in
Programming Questions
•
9 months ago
Hi,
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);
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.
1