Wednesday, January 25, 2012

Change Marker color for GWT Google Map without loading all the Map

Hello,

I'm trying for my first experience with GWT google Map to change the
color of My Marker tag without loading all the Map !
I'm asking if there any somehow the do this with AJAX or something
like that ?

Please any help.

this is my class but there is no variation :


public class MyMapeApplication implements EntryPoint
{


private MapWidget m_map;
Icon m_icon = null;

String [] m_astrcolor = new String []
{IconBuilderI.KSTR_MARKER_BLACK,IconBuilderI.KSTR_MARKER_WHITE,IconBuilderI.KSTR_MARKER_RED,IconBuilderI.KSTR_MARKER_GREEN,IconBuilderI.KSTR_MARKER_BLUE};
Timer m_timer = null;

/**
* This is the entry point method.
*/
public void onModuleLoad()
{

try
{

Maps.loadMapsApi("xxxxxxxxxx", "2", false, new
Runnable() {
public void run() {
buildUi();
System.out.println("run maps");
}
});


m_timer = new Timer()
{
int intCounter = 0;
public void run()
{
if(intCounter == 5){
intCounter = 0;
}

m_icon.setImageURL(m_astrcolor[intCounter]);
System.out.println("Color :
"+m_astrcolor[intCounter]);
intCounter ++;
}
};

m_timer.scheduleRepeating(1000);

}
catch (Exception e)
{
System.out.println(e.getMessage());
}

}

private void buildUi()
{
try
{
// Open a map centered on Cawker City, KS USA
LatLng cawkerCity = LatLng.newInstance(39.509, -98.434);

LatLng cawkerCity1 = LatLng.newInstance(39.509, -78.536);

final MapWidget map = new MapWidget(cawkerCity, 2);
map.setSize("100%", "100%");
// Add some controls for the zoom level
map.addControl(new LargeMapControl());

// Add a marker
Marker marker = new Marker(cawkerCity);
map.addOverlay(marker);

//icon

m_icon = Icon.newInstance(IconBuilderI.KSTR_MARKER_BLUE);
m_icon.setShadowURL(IconBuilderI.KSTR_SMALL_SHADOW);
m_icon.setIconSize(Size.newInstance(12, 20));
m_icon.setShadowSize(Size.newInstance(22, 20));
m_icon.setIconAnchor(Point.newInstance(6, 20));
m_icon.setInfoWindowAnchor(Point.newInstance(5, 1));

MarkerOptions options = MarkerOptions.newInstance();
options.setIcon(m_icon);

map.addOverlay(new Marker(cawkerCity1,options));

// Add an info window to highlight a point of interest
map.getInfoWindow().open(map.getCenter(),new
InfoWindowContent("World's Largest Ball of Sisal Twine"));

final DockLayoutPanel dock = new
DockLayoutPanel(Style.Unit.PX);
dock.addNorth(map, 500);

// Add the map to the HTML host page
RootLayoutPanel.get().add(dock);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}

}

}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment