Package com.buzzcoders.yasw.widgets.map.core

Examples of com.buzzcoders.yasw.widgets.map.core.LatLng


    super(browser, name, mapSupport);
  }

  @Override
    public Object function (Object[] arguments) {
    LatLng newPosition = GMapUtils.getPosition(arguments);
        int markerIdx = ((Double) arguments[2]).intValue();
        getMapSupport().updateMarkerPosition(markerIdx, newPosition);
        return null;
    }
View Full Code Here


    super(browser, name, mapSupport);
  }

  @Override
  public Object function(Object[] arguments) {
    LatLng newPosition = GMapUtils.getPosition(arguments);
    getMapSupport().setMapCenter(newPosition);
    return null;
  }
View Full Code Here

     
    return container;
  }
 
  private void locateAddress(String addressText) {
    LatLng coords = GMapUtils.getAddressCoordinates(addressText);
    if(coords!=null) {
      mapTile.getJavascriptMapSupport().evaluateJavascript("myMap.panTo(new google.maps.LatLng("+coords.getLat()+","+coords.getLng()+"));");
      mapTile.getJavascriptMapSupport().clearMarkers();
      mapTile.getJavascriptMapSupport().addNewMarker(new Marker(coords));
      mapTile.getJavascriptMapSupport().evaluateJavascript("myMap.mapMarkers[0].setDraggable(false);");
    }
    else {
View Full Code Here

   * @return {@link MarkerOptions} instance
   */
  public static MarkerOptions getMarkerOptions(Object[] arguments) {
    MarkerOptions options = new MarkerOptions();
    // LatLng
    options.setPosition(new LatLng(
        (Double) arguments[OPTIONS_LAT_INDEX],
        (Double) arguments[OPTIONS_LNG_INDEX]));
    // Draggable
    options.setDraggable((Boolean)arguments[OPTIONS_DRAGGABLE_INDEX]);
    // Animation
View Full Code Here

   *
   * @param arguments the arguments containing the information
   * @return the latitude and longitude information
   */
  public static LatLng getPosition(Object[] arguments) {
    return new LatLng((Double) arguments[0],(Double) arguments[1]);
  }
View Full Code Here

   *
   * @param addressText the address to look
   * @return the latitude and longitude information
   */
  public static LatLng getAddressCoordinates(String addressText) {
    LatLng coordinates = null;
    GetMethod locateAddressGET = null;
    HttpClient client = null;
    try {
      String addressUrlEncoded = URLEncoder.encode(addressText, "UTF-8");
      String locationFindURL = "http://maps.google.com/maps/api/geocode/json?sensor=false&address="+addressUrlEncoded;
      client = new HttpClient();
      locateAddressGET = new GetMethod(locationFindURL);
      int httpRetCode = client.executeMethod(locateAddressGET);
      if(httpRetCode == HttpStatus.SC_OK){
          String responseBodyAsString = locateAddressGET.getResponseBodyAsString();
        ObjectMapper mapper = new ObjectMapper();
        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
        mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
        JsonNode jsonRoot = mapper.readTree(responseBodyAsString);
        JsonNode location = jsonRoot.path("results").get(0).path("geometry").path("location");
        JsonNode lat = location.get("lat");
        JsonNode lng = location.get("lng");
        coordinates = new LatLng(lat.asDouble(),lng.asDouble());
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      if(locateAddressGET!=null) locateAddressGET.releaseConnection();
View Full Code Here

    this.mapId = mapId;
  }

  @Override
  public LatLng getMapCenter() {
    return new LatLng(
        (Double) getBrowserControl().evaluate("return "+mapId+".getCenter().lat();"),
        (Double) getBrowserControl().evaluate("return "+mapId+".getCenter().lng();"));
  }
View Full Code Here

      goToBtn.setLayoutData(new GridData(SWT.RIGHT,SWT.CENTER,true,false,2,1));
      goToBtn.setText(Messages.GMapsDetailsPanel_FindBtn);
      goToBtn.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
          LatLng coords = GMapUtils.getAddressCoordinates(addressLocation.getText());
          if(coords!=null) {
          map.getJavascriptMapSupport().evaluateJavascript("myMap.panTo(new google.maps.LatLng("+coords.getLat()+","+coords.getLng()+"));");
          map.getJavascriptMapSupport().evaluateJavascript("myMap.addMarker(new google.maps.LatLng("+coords.getLat()+","+coords.getLng()+"));");
          }
          else {
            MessageDialog.openError(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.GMapsDetailsPanel_LocationErrorTitle, Messages.GMapsDetailsPanel_LocationErrorMsg);
View Full Code Here

    }
   
    @Override
    public void addNewMarker(Marker newMarker) {
      super.addNewMarker(newMarker);
      LatLng position = newMarker.getPosition();
      markersList.add(position.getLat() + " : " + position.getLng());
    }
View Full Code Here

    }
   
    @Override
    public void addNewMarker(Marker newMarker) {
      super.addNewMarker(newMarker);
      LatLng position = newMarker.getPosition();
      markersWidget.add(
          String.format("%.6f",position.getLat()) + " : " + String.format("%.6f",position.getLng()));
      markers.add(position);
    }
View Full Code Here

TOP

Related Classes of com.buzzcoders.yasw.widgets.map.core.LatLng

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.