Combining two frames (unfolding maps)

hello again , can anyone of you help me with this.

i made 2 frames and want to make them in one but the issue is whenever i want to do that my button always get lost and not able to see it but when i close/comment map.draw(); function . i can see button but then my map is not loading. here are my 2 codes.

1 code :

    import de.fhpotsdam.unfolding.providers.Microsoft;
    import de.fhpotsdam.unfolding.*;
    import de.fhpotsdam.unfolding.utils.*;
    import de.fhpotsdam.unfolding.marker.*;
    import de.fhpotsdam.unfolding.geo.*;



    UnfoldingMap map ;
    UnfoldingMap currentMap;
    SimpleLinesMarker connectionMarker;


    void settings() {

      // size(400,400);

      size(800,600,P3D);

      map = new UnfoldingMap(this, new Microsoft.AerialProvider());
      MapUtils.createDefaultEventDispatcher(this, map);
      currentMap = map;

      map = new UnfoldingMap(this,0,0,width*0.8,height);
      Location startLocation = new Location(32.2, 76.3);
      Location endLocation = new Location(53.35, -6.26);
      SimpleLinesMarker connectionMarker = new SimpleLinesMarker(startLocation, endLocation);
      MapUtils.createDefaultEventDispatcher(this, map);

    }


    void draw() {
      background(0);
      currentMap.draw();

    }

    void mousePressed() {
      exit(); 
    }

And My 2nd Code ;

import controlP5.*;

ControlFrame cf;
ControlP5 cp5;



void setup(){
  cf = new ControlFrame(this, 400, 400, "Controls");
  surface.setLocation(430,10);
  noStroke();


}


class ControlFrame extends PApplet {

  int w, h;
  PApplet parent;
  ControlP5 cp5;

  public ControlFrame(PApplet _parent, int _w, int _h, String _name) {
    super();   
    parent = _parent;
    w=_w;
    h=_h;
    PApplet.runSketch(new String[]{this.getClass().getName()}, this);
  }

  public void settings() {
    size(w,h);
  }

  public void setup() {
    surface.setLocation(10,10);
    cp5 = new ControlP5(this);

  cp5.addTab("extra")
     .setColorBackground(color(0, 160, 100))
     .setColorLabel(color(255))
     .setColorActive(color(255,128,0))
     ;

  // if you want to receive a controlEvent when
  // a  tab is clicked, use activeEvent(true)

  cp5.getTab("default")
     .activateEvent(true)
     .setLabel("my default tab")
     .setId(1)
     ;

  cp5.getTab("extra")
     .activateEvent(true)
     .setId(2)
     ;


  // create a few controllers

  cp5.addButton("button")
     .setBroadcast(false)
     .setPosition(20,20)
     .setSize(80,40)
     .setValue(1)
     .setBroadcast(true)
     .getCaptionLabel().align(CENTER,CENTER)
     ;

  cp5.addButton("buttonValue")
     .setBroadcast(false)
     .setPosition(110,20)
     .setSize(80,40)
     .setValue(2)
     .setBroadcast(true)
     .getCaptionLabel().align(CENTER,CENTER)
     ;
  //  cp5.addNumberbox("seed").plugTo(parent, "seed").setRange(0, 360).setValue(1).setPosition(100, 10).setSize(100,20);

  }

  void draw() {
    background(40);
  }
}

Answers

  • @GoToLoop : yes i know that was one of my thread but these are working codes and i just a way that how i can make them in one sketch " button with Map"

  • You want the buttons to appear on top of the map?

    Also, is there a reason to have two unfolding maps objects, currentMap and map?

    You we need to become familiar with javadocs to be able to use unfoldingmaps to its full potential: http://unfoldingmaps.org/javadoc/

    For example, you are drawing your map over your full sketch area. When instantiating your unfolding map object, you can limit the actual drawing area of this object. Check example http://unfoldingmaps.org/examples/50_overviewAndDetail

    This does not answer your question.

    Kf

  • Here is a demo for you to consider. This addresses your question.

    Kf

    import controlP5.*;  
    
    import de.fhpotsdam.unfolding.providers.Microsoft;
    import de.fhpotsdam.unfolding.*;
    import de.fhpotsdam.unfolding.utils.*;
    import de.fhpotsdam.unfolding.marker.*;
    import de.fhpotsdam.unfolding.geo.*;
    
    int w, h;
    ControlP5 cp5;
    
    UnfoldingMap map ;
    UnfoldingMap currentMap;
    SimpleLinesMarker connectionMarker;
    
    
    
    void settings() {
      size(800, 600, P3D);
    }
    
    void setup() {
      map = new UnfoldingMap(this, 100, 100, 400, 400, new Microsoft.AerialProvider());   //API Reference @  http://unfoldingmaps.org/javadoc/ 
    
      MapUtils.createDefaultEventDispatcher(this, map);
      currentMap = map;
    
      map = new UnfoldingMap(this, 0, 0, width*0.8, height);
      Location startLocation = new Location(32.2, 76.3);
      Location endLocation = new Location(53.35, -6.26);
      SimpleLinesMarker connectionMarker = new SimpleLinesMarker(startLocation, endLocation);
      MapUtils.createDefaultEventDispatcher(this, map);
    
      //cf = new ControlFrame(this, 400, 400, "Controls");
      surface.setLocation(430, 10);
      noStroke();
    
      setupCon();
    }
    
    
    void draw() {
      background(40);
      currentMap.draw();
    }
    
    
    
    
    
    void setupCon() {
      surface.setLocation(10, 10);
      cp5 = new ControlP5(this);
    
      cp5.addTab("extra")
        .setColorBackground(color(0, 160, 100))
        .setColorLabel(color(255))
        .setColorActive(color(255, 128, 0))
        ;
    
      // if you want to receive a controlEvent when
      // a  tab is clicked, use activeEvent(true)
    
      cp5.getTab("default")
        .activateEvent(true)
        .setLabel("my default tab")
        .setId(1)
        ;
    
      cp5.getTab("extra")
        .activateEvent(true)
        .setId(2)
        ;
    
    
      // create a few controllers
    
      cp5.addButton("button")
        .setBroadcast(false)
        .setPosition(20, 20)
        .setSize(80, 40)
        .setValue(1)
        .setBroadcast(true)
        .getCaptionLabel().align(CENTER, CENTER)
        ;
    
      cp5.addButton("buttonValue")
        .setBroadcast(false)
        .setPosition(110, 20)
        .setSize(80, 40)
        .setValue(2)
        .setBroadcast(true)
        .getCaptionLabel().align(CENTER, CENTER)
        ;
      //  cp5.addNumberbox("seed").plugTo(parent, "seed").setRange(0, 360).setValue(1).setPosition(100, 10).setSize(100,20);
    }
    
  • @kfrajer : thank you so much but still its not working for me .

Sign In or Register to comment.