package com.google.gwt.maps.testing.client.maps;
/*
* #%L
* GWT Maps API V3 - Showcase
* %%
* Copyright (C) 2011 - 2012 GWT Maps API V3
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
import com.google.gwt.core.client.GWT;
import com.google.gwt.maps.client.LoadApi;
import com.google.gwt.maps.client.LoadApi.Language;
import com.google.gwt.maps.client.MapOptions;
import com.google.gwt.maps.client.MapTypeId;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.base.LatLng;
import com.google.gwt.maps.client.events.click.ClickMapEvent;
import com.google.gwt.maps.client.events.click.ClickMapHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
public class LanguageMapWidget extends Composite {
private final VerticalPanel pWidget;
private MapWidget mapWidget;
public LanguageMapWidget() {
pWidget = new VerticalPanel();
initWidget(pWidget);
draw();
}
private void draw() {
HorizontalPanel hp = new HorizontalPanel();
hp.add(new HTML("Language use example."));
pWidget.clear();
pWidget.add(hp);
Runnable onload = new Runnable() {
public void run() {
drawMap();
}
};
LoadApi.go(onload, LoadApi.LoadLibrary.values(), false, Language.CHINESE_SIMPLIFIED);
}
private void drawMap() {
LatLng center = LatLng.newInstance(49.496675, -102.65625);
MapOptions opts = MapOptions.newInstance();
opts.setZoom(4);
opts.setCenter(center);
opts.setMapTypeId(MapTypeId.HYBRID);
mapWidget = new MapWidget(opts);
pWidget.add(mapWidget);
mapWidget.setSize("750px", "500px");
mapWidget.addClickHandler(new ClickMapHandler() {
@Override
public void onEvent(ClickMapEvent event) {
// TODO fix the event getting, getting ....
GWT.log("clicked on latlng=" + event.getMouseEvent().getLatLng());
}
});
}
}