Example usage for com.google.gwt.gdata.client.maps FeatureEntryCallback FeatureEntryCallback

List of usage examples for com.google.gwt.gdata.client.maps FeatureEntryCallback FeatureEntryCallback

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.maps FeatureEntryCallback FeatureEntryCallback.

Prototype

FeatureEntryCallback

Source Link

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsCreateMapFeatureDemo.java

License:Apache License

/**
 * Create a feature by inserting a feature entry into
 * a feature feed for a given map./*ww  w. ja v  a2  s.  co  m*/
 * Set the feature's title to an arbitrary string. Here
 * we prefix the title with 'GWT-Maps-Client' so that
 * we can identify which features were created by this demo.
 * A value is also provided for the feature's postal address
 * along with the KML content which defines the placemarks
 * for this feature.
 * On success and failure, display a status message.
 * 
 * @param mapId The id of the map into which to insert the
 * new feature entry
 */
private void insertMapFeature(String mapId) {
    showStatus("Creating map feature...", false);
    FeatureEntry entry = FeatureEntry.newInstance();
    entry.setTitle(Text.newInstance());
    entry.getTitle().setText("GWT-Maps-Client - inserted feature");
    PostalAddress address = PostalAddress.newInstance();
    address.setLabel("Google Headquarters");
    address.setRel(PostalAddress.REL_WORK);
    address.setValue("1600 Amphitheatre Parkway\nMountain View, CA 94043");
    entry.setPostalAddress(address);
    KmlContent kml = KmlContent.newInstance();
    kml.setType(KmlContent.TYPE_APPLICATION_VND_GOOGLE_EARTH_KML_XML);
    kml.setText("<Placemark xmlns=\"http://www.opengis.net/kml/2.2\">" + "<name>Faulkner's Birthplace</name>"
            + "<description/><Point><coordinates>-89.520753,34.360902,0.0" + "</coordinates></Point><"
            + "/Placemark>");
    entry.setContent(kml);
    String featuresFeedUri = mapId.replace("/feeds/maps/", "/feeds/features/") + "/full";
    service.insertEntry(featuresFeedUri, entry, new FeatureEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating a map feature: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureEntry result) {
            showStatus("Created a map feature.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsDeleteMapFeatureDemo.java

License:Apache License

/**
 * Delete a fature entry using the Maps service and
 * the feature entry uri.//from ww  w. java 2  s . co  m
 * On success and failure, display a status message.
 * 
 * @param featureEntryUri The uri of the feature entry to delete
 */
private void deleteFeature(String featureEntryUri) {
    showStatus("Deleting map feature...", false);
    service.deleteEntry(featureEntryUri, new FeatureEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while deleting a map feature: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureEntry result) {
            showStatus("Deleted a map feature.", false);
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.MapsUpdateMapFeatureDemo.java

License:Apache License

/**
 * Update a map feature by making use of the updateEntry
 * method of the Entry class./*from   w  ww  . jav a2 s.  c o  m*/
 * Set the feature's title to an arbitrary string. Here
 * we prefix the title with 'GWT-Maps-Client' so that
 * we can identify which features were updated by this demo.
 * On success and failure, display a status message.
 * 
 * @param targetFeature The feature entry which to update
 */
private void updateFeature(FeatureEntry targetFeature) {
    showStatus("Updating map feature...", false);
    targetFeature.setTitle(Text.newInstance());
    targetFeature.getTitle().setText("GWT-Maps-Client - updated feature");
    targetFeature.updateEntry(new FeatureEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while updating a map feature: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureEntry result) {
            showStatus("Updated a map feature.", false);
        }
    });
}