Code Monkey home page Code Monkey logo

Comments (11)

branflake2267 avatar branflake2267 commented on July 17, 2024

maybe I misspelled something. hmmmm. I'll check. Thanks for the report.

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024
Maybe I should add a setTypes(List<String>) :)

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

Wow, your right about the strings... I see there are hundreds of types. So I'm overloading it.

public final void setTypes(JsArrayString types) {...}

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

I haved added an overloaded method for this. Thanks for the issue report. I also added example map, but haven't deployed it to the live demos yet. If you like to get the latest method sync to the source. Will get an updated jar available shortly.

private void searchRequest(LatLng clickLocation) {
      String[] searchTypes = new String[1];
      searchTypes[0] = "establishment";

      JsArrayString searchJstypes = ArrayHelper.toJsArrayString(searchTypes);

      PlaceSearchRequest request = PlaceSearchRequest.newInstance(); 
    request.setLocation(clickLocation); 
    request.setRaidus(500); 
    // TODO add more AutocompleteTypes...
    //request.setTypes(AutocompleteType.ESTABLISHMENT);
    request.setTypes(searchJstypes);

    PlacesService placeService = PlacesService.newInstance(mapWidget.getElement(), mapWidget);
    placeService.search(request, new PlaceSearchHandler() {                 
        @Override
        public void onCallback(JsArray<PlaceResult> results, PlacesServiceStatus status) {
          // TODO add some popup to display the results
          Window.alert("I found this many places " + results.length());
        }
    });     
  }

from gwt-maps-v3-api.

cancerberoSgx avatar cancerberoSgx commented on July 17, 2024

in mine jsni projects I use a method for fransforming a java array to a js array:

public class JsUtil {
    public static JsArrayString toJsArrayString(String[] a) {
        if(a==null)
            return null;
        JsArrayString jsa = JsArrayNumber.createArray().<JsArrayString>cast();
        for (int i = 0; i < a.length; i++) {
            jsa.push(a[i]);
        }
        return jsa;
    }
}

then you can

public final native void setTypes(String... types)/*-{
      @org.sgx.madrenecesidad.client.util.JsUtil::toJsArrayString([Ljava/lang/String;)(types);
}-*/;

and that becomes much more java friendly:

req.setTypes("store", "bus_station"); 

or

req.setTypes(PlacesService.TYPE_STORE, PlacesService.TYPE_BUSSTATION}); 

If I were you I would remove class AutocompleteTypes. Regards

from gwt-maps-v3-api.

cancerberoSgx avatar cancerberoSgx commented on July 17, 2024

thanks for adding the method!

PlacesService placeService = PlacesService.newInstance(mapWidget.getElement(), mapWidget);

this is wrong (my code). the map will be erased when clicked. I'm not understanding how to build a PlacesServices with your Java API. In the documentation (https://developers.google.com/maps/documentation/javascript/places#place_searches) says:

service = new google.maps.places.PlacesService(map);

but your constructor requires 2 arguments, and in fact you are calling :

private static final native PlacesService createJso(Element attrContainer, MapImpl map) /*-{
    return new $wnd.google.maps.places.PlacesService(attrContainer, map);
  }-*/;

What is this attrContainer param ?

Regards, I will try to get the sources and make a pull request to you with my changes.

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

Good point, that crossed my mind to do it that way.

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

That second issue... Would you mind filing that under a new issue? :)

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

Good idea. I'm overloading the types. :)

  public final void setTypes(List<String> types) {
    setTypes((String[]) types.toArray());
  }

  public final void setTypes(String... types) {
    setTypes(ArrayHelper.toJsArrayString(types));
  }

  public final void setTypes(JsArrayString types) {
    setTypesImpl(types);
  }

from gwt-maps-v3-api.

branflake2267 avatar branflake2267 commented on July 17, 2024

I pulled then merged the code with master. :)

from gwt-maps-v3-api.

cancerberoSgx avatar cancerberoSgx commented on July 17, 2024

thanks! and done a second issue at #43

from gwt-maps-v3-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.