package com.howudodat.test.ui;
import com.codename1.googlemaps.MapContainer;import com.codename1.googlemaps.MapContainer.MapObject;import com.codename1.location.Location;import com.codename1.location.LocationListener;import com.codename1.location.LocationManager;import com.codename1.maps.Coord;import com.codename1.maps.MapListener;import com.codename1.ui.Command;import com.codename1.ui.Component;import com.codename1.ui.Display;import com.codename1.ui.EncodedImage;import com.codename1.ui.FontImage;import com.codename1.ui.Image;import com.codename1.ui.Toolbar;import com.codename1.ui.events.ActionEvent;import com.codename1.ui.events.ActionListener;import com.codename1.ui.layouts.BorderLayout;import com.codename1.ui.plaf.UIManager;import com.codename1.ui.util.Resources;
public class FrmMap extends com.codename1.ui.Form { protected MapContainer cnt = new MapContainer(); protected MapObject mo = null; protected Image image0 = FontImage.createMaterial(FontImage.MATERIAL_HOME, UIManager.getInstance().getComponentStyle("Command"), 5); protected Image image1 = FontImage.createMaterial(FontImage.MATERIAL_REFRESH, UIManager.getInstance().getComponentStyle("Command"), 5); protected Image image2 = FontImage.createMaterial(FontImage.MATERIAL_LIST, UIManager.getInstance().getComponentStyle("Command"), 5); public FrmMap() { this(Resources.getGlobalResources()); } public FrmMap(Resources resourceObjectInstance) { initManualComponents(); Display.getInstance().callSerially(() -> { centerMapToLocation(); }); } protected void initManualComponents() { setLayout(new BorderLayout()); setTitle("Map"); setName("FrmMap"); // sidebar if (getToolbar() == null) { setToolbar(new Toolbar()); } FrmSideMenu.CreateToolbar(getToolbar());
this.setScrollable(false); this.addComponent(BorderLayout.CENTER, cnt); cnt.addMapListener(new MapListener() { @Override public void mapPositionUpdated(Component source, int zoom, Coord center) { } }); Command cmdRefresh = new Command("",FontImage.createMaterial(FontImage.MATERIAL_REFRESH, UIManager.getInstance().getComponentStyle("Command"), 5)) { public void actionPerformed(com.codename1.ui.events.ActionEvent ev) { onRefresh(); } }; Command cmdList = new Command("",FontImage.createMaterial(FontImage.MATERIAL_LIST, UIManager.getInstance().getComponentStyle("Command"), 5)) { public void actionPerformed(com.codename1.ui.events.ActionEvent ev) { onList(); } }; this.getToolbar().addCommandToRightBar(cmdRefresh); this.getToolbar().addCommandToRightBar(cmdList); } protected void centerMapToLocation() { LocationManager l = LocationManager.getLocationManager(); l.setLocationListener(new LocationListener() { public void locationUpdated(Location loc) { Coord c = new Coord(loc.getLatitude(), loc.getLongitude()); cnt.zoom(c , 13); l.setLocationListener(null); onMapUpdate(13, c); }
public void providerStateChanged(int newState) { } }); }
protected void onMapUpdate(int zoom, Coord center) { mo = cnt.addMarker(EncodedImage.createFromImage(image0, false), center, "test", "test", new ActionListener<ActionEvent>() { public void actionPerformed(ActionEvent evt) { onClickMap(); } } ); } protected void onRefresh() { mo.point.setIcon(image1); repaint(); } protected void onList() { mo.point.setIcon(image2); repaint(); } protected void onClickMap() { System.out.println("whoohoo"); }}So how can I change the icon? Remove the market and add another?
So how can I change the icon? Remove the market and add another?
On Oct 5, 2016 8:14 PM,
That's an internal API that's specifically hidden. I don't recall the exact implementation but if something is package protected it isn't meant for external usage and there is probably a reason....