0

I am using processing 3, and trying to implement an interactive map via gicentre GeoMap library. I have got the U.S. map shown and the hovering feature work i.e. highlight the hovering state. I am wondering is there any way I can zoom into the state in this GeoMap library. Maybe a mouseClick or a mouseMove event to trigger this function. I am not sure how to redraw the map to make it zoom into the selected state. Here is my starting code:

import org.gicentre.geomap.*;

GeoMap geoMap;
int id = -1;
void setup()
{
  size(800, 400);  
  geoMap = new GeoMap(this);  // Create the geoMap object.
  geoMap.readFile("usContinental");   // Read shapefile.
}

void draw()
{
  background(202, 226, 245);  // Ocean colour
  stroke(0,40);               // Boundary colour
  fill(206,173,146);          // Land colour
  //if (id == -1) {
    geoMap.draw();              // Draw the entire map.
  //} else {
  //  geoMap.draw(id);
  //}
  // Find the country at mouse position and draw in different color.
  id = geoMap.getID(mouseX, mouseY);
  if (id != -1)
  {
    fill(180, 120, 120);      // Highlighted land colour.
    geoMap.draw(id);
  }
}

Any idea? Thanks!

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
MC X
  • 337
  • 4
  • 16

1 Answers1

0

Questions like these are best answered by looking at the docs for the library. Here are the docs for the giCentre geoMap library.

According to that, this library basically just shows shape files, without any fancy logic for zooming the map. You could implement this yourself using the scale() function or the camera functions. But you might be best off just finding a library that supports changing the zoom out of the box.

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
  • Thanks Kevin! BTW, do you know any library supports such feature? I tried unfolding map, but I found it performs kind of slow. – MC X Oct 27 '17 at 03:49
  • @zxue Unfolding Maps is the only Processing/Java option I know of. You might have better luck if you google "java mapping library" or something. – Kevin Workman Oct 29 '17 at 16:41