

import java.util.Arrays;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.timelessname.joogle.maps.JoogleMap;
import com.timelessname.joogle.maps.api.GControl;
import com.timelessname.joogle.maps.api.GIcon;
import com.timelessname.joogle.maps.api.GLatLng;
import com.timelessname.joogle.maps.api.GMap2;
import com.timelessname.joogle.maps.api.GMarker;
import com.timelessname.joogle.maps.api.GPolyline;


public class Example1 {

  public static void main(String [] args) throws Exception {
    final Display display = new Display();
    final Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());
    
    JoogleMap jMap = new JoogleMap(shell, SWT.NONE);
    shell.open();
    jMap.blockUntilLoaded();

    GMap2 gMap2 = jMap.getGMap2();
    gMap2.setCenter(new GLatLng(jMap,37.061975, -95.677067), 5);
    gMap2.checkResize();

    gMap2.addControl(new GControl(jMap,GControl.GMapTypeControl));
    gMap2.addControl(new GControl(jMap,GControl.GScaleControl));
    gMap2.addControl(new GControl(jMap,GControl.GSmallMapControl));

    GIcon gIcon = new GIcon(jMap);

    GLatLng a = new GLatLng(jMap,33.979809, -118.048096);
    GLatLng b = new GLatLng(jMap,40.84706, -74.003906);
    
    GMarker gMarker = new GMarker(jMap,a,gIcon);
    gMap2.addOverlay(gMarker);
    
    gMarker = new GMarker(jMap,b,gIcon);
    gMap2.addOverlay(gMarker);
    
    GPolyline gPolyLine = 
      new GPolyline(jMap,
        Arrays.asList(new Object[]{a,b}),
        "#FF0000",
        "4");
    
    gMap2.addOverlay(gPolyLine);

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
    
}
