package solysombra.client.maps;
import java.util.List;
import com.google.gwt.dom.client.Document;
import com.google.maps.gwt.client.GoogleMap;
import com.google.maps.gwt.client.InfoWindow;
import com.google.maps.gwt.client.InfoWindowOptions;
import com.google.maps.gwt.client.LatLng;
import com.google.maps.gwt.client.MapOptions;
import com.google.maps.gwt.client.MapTypeId;
import com.google.maps.gwt.client.Marker;
import com.google.maps.gwt.client.Marker.ClickHandler;
import com.google.maps.gwt.client.MarkerOptions;
import com.google.maps.gwt.client.MouseEvent;
public class CustomizedMap1 {
public static void showMapCiudad(LatLng myLatLng) {
System.out.println(myLatLng);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(13.0);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
GoogleMap
.create(Document.get().getElementById("map_canvas"), myOptions);
System.out.println("llega a crear el mapa !!");
}
public static void showMapSitio(LatLng myLatLng, String address) {
System.out.println(myLatLng);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(15.0);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
GoogleMap map = GoogleMap.create(
Document.get().getElementById("map_canvas"), myOptions);
System.out.println("llega a crear el mapa !!");
MarkerOptions markerOpts = MarkerOptions.create();
markerOpts.setPosition(myLatLng);
markerOpts.setTitle(address);
markerOpts.setMap(map);
final Marker marc = Marker.create(markerOpts);
}
public static void showMapPlaces(LatLng myLatLng, List<String> addresses) {
System.out.println(myLatLng);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(13.0);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
final GoogleMap map = GoogleMap.create(
Document.get().getElementById("map_canvas"), myOptions);
System.out.println("llega a crear el mapa !!");
for (String add : addresses) {
String[] trozos = add.split(",");
if (trozos.length == 4) {
LatLng pto = LatLng.create(new Double(trozos[0]), new Double(
trozos[1]));
InfoWindowOptions infoWindowOpts = InfoWindowOptions.create();
infoWindowOpts.setContent("<h4>" + trozos[2] + "</h4>");
final InfoWindow infoWindow = InfoWindow.create(infoWindowOpts);
MarkerOptions markerOpts = MarkerOptions.create();
markerOpts.setPosition(pto);
markerOpts.setTitle(trozos[2]);
markerOpts.setMap(map);
final Marker marc = Marker.create(markerOpts);
marc.addClickListener(new ClickHandler() {
@Override
public void handle(MouseEvent event) {
infoWindow.open(map, marc);
}
});
}
}
}
public static void showMapSitioSol(LatLng myLatLng, String address,
Double porc) {
System.out.println(myLatLng);
MapOptions myOptions = MapOptions.create();
myOptions.setZoom(15.0);
myOptions.setCenter(myLatLng);
myOptions.setMapTypeId(MapTypeId.ROADMAP);
GoogleMap map = GoogleMap.create(
Document.get().getElementById("map_canvas"), myOptions);
System.out.println("llega a crear el mapa !!");
MarkerOptions markerOpts = MarkerOptions.create();
markerOpts.setPosition(myLatLng);
markerOpts.setTitle(address);
markerOpts.setMap(map);
Marker marc = Marker.create(markerOpts);
if (porc < 34.0)
marc.setIcon("http://maps.google.com/mapfiles/ms/icons/blue-dot.png");
else if (porc < 51)
marc.setIcon("http://maps.google.com/mapfiles/ms/icons/purple-dot.png");
else if (porc < 68)
marc.setIcon("http://maps.google.com/mapfiles/ms/icons/green-dot.png");
else if (porc < 85)
marc.setIcon("http://maps.google.com/mapfiles/ms/icons/red-dot.png");
else
marc.setIcon("http://maps.google.com/mapfiles/ms/icons/yellow-dot.png");
}
}