Giter VIP home page Giter VIP logo

locationtextfield's Introduction

LocationTextField Add-on for Vaadin 7

LocationTextField is an UI component add-on for Vaadin 7 that geocodes addresses using a configurable geocoder. Any class implementing org.vaadin.addons.locationtextfield.LocationProvider can be used with LocationTextField. There are currently two LocationProvider implementations provided; one using Google's geocoder and the other using OpenStreetMap's Nominatim. Adding new implementations is trivial. Results for the geocoded address are available to choose from in a drop-down menu.

Download release

Official releases of this add-on are available at Vaadin Directory. For Maven instructions, download and reviews, go to http://vaadin.com/addon/locationtextfield

Building and running demo

git clone https://github.com/markathomas/LocationTextField.git mvn clean install cd demo mvn jetty:run

To see the demo, navigate to http://localhost:8080/

Development with Eclipse IDE

For further development of this add-on, the following tool-chain is recommended:

  • Eclipse IDE
  • m2e wtp plug-in (install it from Eclipse Marketplace)
  • Vaadin Eclipse plug-in (install it from Eclipse Marketplace)
  • JRebel Eclipse plug-in (install it from Eclipse Marketplace)
  • Chrome browser

Importing project

Choose File > Import... > Existing Maven Projects

Note that Eclipse may give "Plugin execution not covered by lifecycle configuration" errors for pom.xml. Use "Permanently mark goal resources in pom.xml as ignored in Eclipse build" quick-fix to mark these errors as permanently ignored in your project. Do not worry, the project still works fine.

Debugging server-side

If you have not already compiled the widgetset, do it now by running vaadin:install Maven target for locationtextfield-root project.

If you have a JRebel license, it makes on the fly code changes faster. Just add JRebel nature to your locationtextfield-demo project by clicking project with right mouse button and choosing JRebel > Add JRebel Nature

To debug project and make code modifications on the fly in the server-side, right-click the locationtextfield-demo project and choose Debug As > Debug on Server. Navigate to http://localhost:8080/locationtextfield-demo/ to see the application.

Debugging client-side

The most common way of debugging and making changes to the client-side code is dev-mode. To create debug configuration for it, open locationtextfield-demo project properties and click "Create Development Mode Launch" button on the Vaadin tab. Right-click newly added "GWT development mode for locationtextfield-demo.launch" and choose Debug As > Debug Configurations... Open up Classpath tab for the development mode configuration and choose User Entries. Click Advanced... and select Add Folders. Choose Java and Resources under locationtextfield/src/main and click ok. Now you are ready to start debugging the client-side code by clicking debug. Click Launch Default Browser button in the GWT Development Mode in the launched application. Now you can modify and breakpoints to client-side classes and see changes by reloading the web page.

Another way of debugging client-side is superdev mode. To enable it, uncomment devModeRedirectEnabled line from the end of DemoWidgetSet.gwt.xml located under locationtextfield-demo resources folder and compile the widgetset once by running vaadin:compile Maven target for locationtextfield-demo. Refresh locationtextfield-demo project resources by right clicking the project and choosing Refresh. Click "Create SuperDevMode Launch" button on the Vaadin tab of the locationtextfield-demo project properties panel to create superder mode code server launch configuration and modify the class path as instructed above. After starting the code server by running SuperDevMode launch as Java application, you can navigate to http://localhost:8080/locationtextfield-demo/?superdevmode. Now all code changes you do to your client side will get compiled as soon as you reload the web page. You can also access Java-sources and set breakpoints inside Chrome if you enable source maps from inspector settings.

Release notes

Version 2.0.0

  • Vaadin 7 version using newer GWT SuggestBox widget

Issue tracking

The issues for this add-on are tracked on its github.com page. All bug reports and feature requests are appreciated.

Contributions

Contributions are welcome, but there are no guarantees that they are accepted as such. Process for contributing is the following:

  • Fork this project
  • Create an issue to this project about the contribution (bug or feature) if there is no such issue about it already. Try to keep the scope minimal.
  • Develop and test the fix or functionality carefully. Only include minimum amount of code needed to fix the issue.
  • Refer to the fixed issue in commit
  • Send a pull request for the original project
  • Comment on the original issue that you have implemented a fix for it

License & Author

Add-on is distributed under Apache License 2.0. For license terms, see LICENSE.txt.

LocationTextField is written by Mark Thomas

Developer Guide

Getting started

Here is a simple example on how to try out the add-on component:

final LocationTextField ltf = new LocationTextField(OpenStreetMapGeocoder.getInstance(); ltf.geocode("New York City, NY")

For a more comprehensive example, see locationtextfield-demo/src/test/java/org/vaadin/addons/ltf/demo/DemoUI.java

locationtextfield's People

Contributors

markathomas avatar yamperboy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

locationtextfield's Issues

Widgetset does not contain implementation

When using this addon I get this message:

"Widgetset does not contain implementation for org.vaadin.addons.locationtextfield.LocationTextField. Check its @ClientWidget mapping, widgetsets GWT module description file and re-compile your widgetset. In case you have downloaded a vaadin add-on package, you might want to refer to add-on instructions. Unrendered UIDL:
-Unrendered UIDL
-org.vaadin.addons.locationtextfield.LocationTextField(NO CLIENT IMPLEMENTATION FOUND) id=PID2 width=100.0% immediate=true caption=Address: pagelength=10 filteringmode=0 totalitems=0 textChanged=true iem=LAZY iet=1000 eke=true
-variables
selected=
filter=
page=0
ltfFilter=
-options"

I'm using a ton of other addons, and they are all working correctly.

I'm using Eclipse, if this can be useful.

On a side note, I've also had to manually add the json/slf4j jars to my widgetset, as I could not make the addon work as a standalone.

No longer working!

Hi,
I keep getting the following error. I have not altered the code from this demo. Any help appreciated.

ERROR org.vaadin.addons.locationtextfield.AbstractGeocoderController - Error geocoding query: New York City, NY
org.vaadin.addons.locationtextfield.GeocodingException: A JSONArray text must start with '[' at character 1
at org.vaadin.addons.locationtextfield.URLConnectionGeocoder.geocode(URLConnectionGeocoder.java:64)
at org.vaadin.addons.locationtextfield.AbstractGeocoderController.geocode(AbstractGeocoderController.java:55)
at org.vaadin.addons.locationtextfield.LocationTextField.setText(LocationTextField.java:276)
at org.vaadin.addons.locationtextfield.LocationTextField.geocode(LocationTextField.java:257)
at org.vaadin.addons.ltf.demo.DemoUI$2.buttonClick(DemoUI.java:90)

as icon set to be inside; the icon is not correctly displayed

The following is a screen dump; you can see the search icon of location input text field was moved to the left bottom corner now.

image

`final private LocationTextField ltf = new LocationTextField<>(GoogleGeocoder.getInstance());
final private Button find = new Button("Find");
final private CssLayout findByLocation = new CssLayout(ltf, find);

final private GoogleMap googleMap = new GoogleMap(apiKey, null, null);
final private Panel mapPanel = new Panel(googleMap);

@Autowired
private YardService yardService;

public FindView() {
super.setSizeFull();
super.setMargin(true);
super.setSpacing(true);
super.addComponents(findByLocation, mapPanel);

mapPanel.setSizeFull();
setLtf();
setMap();

}

private void setLtf() {
//ltf.setCaption("Find a shared Yard closing to you");
ltf.setWidth("400px");
ltf.setInputPrompt("Insert an location: ");
ltf.setStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
ltf.setIcon(VaadinIcons.SEARCH);

ltf.addLocationValueChangeListener((HasValue.ValueChangeEvent<GeocodedLocation> e) -> {
    googleMap.clearMarkers();
    LatLon ll = new LatLon(e.getValue().getLat(), e.getValue().getLon());
    setMapCenter(ll);
    setMapMarker(ll);
});

ltf.setDelay(800);

ltf.setLocation(new GeocodedLocation());

}`

Problem with css

HI!
Thank-you for you work.

But we have a problem with the styles: the LocationTextFieldWidgetset imports the Standard themes from GWT, to use its styles in the popup.

But this breaks the whole theme of our application: we use Valo, and including the LocationTextFieldWidgetset the Lato font got replaced with Arial (provided by Standard).
We had to replace the LocationTextFieldWidgetset with another version that does not use Standard.

Compatibility with Java 1.8

I cannot reproduce the issue today but I am leaving this here in case anyone else runs into it.

When I first tried displaying the LocationTextField component I was getting a ClassNotFoundException for com.sun.org.apache.bcel.internal.util.Objects.java. The only thing I found about this class was in the 7u40-b43 JDK. I am running:

$ java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

I found the source code and created the file in my projects (DISGUSTING HACKS AT 3AM!) to get everything to work. If I delete the class now, everything still works. Not sure what was happening.

/*
* Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.  Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
package com.sun.org.apache.bcel.internal.util;

public final class Objects {
    private Objects() {
        throw new IllegalAccessError();
    }

    public static int hashCode(final Object o) {
        return o == null ? 0 : o.hashCode();
    }

    public static boolean equals(Object one, Object two) {
        return one == two || one != null && one.equals(two);
    }
}

.getText() and null values

Hi,
It seems the .getText() will not return the displayed text in the widget if that has a length less than the MinimumQueryCharacters. In that case it will return the previous value which is not nice.
That presents a problem since I can’t know if the user has updated the LocationTextField with a null value.
Thanks for the effort.

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.