Add Gmap Marker programatically
Posted: 19 Jul 2010, 16:29
Hi,
i'm trying to figure out, how to set a marker programatoically via the pointSelectListener listener.
In my backing bean i used this code:
in the View i've a gmap component
so, when i'm clicking at a point, nothing happens, just the growl is shown. if i add an id to my p:gmap and add it to the onPointSelectUpdate event, the gmap is reloaded every time i click on the map but i see one, and every time only one marker. I would like to add multiple markers there, how to realize this? with a list of markers?
Any hints? Is there a way, that i can even allow setting markers, or polygons via links? i mean one link "marker" the seconde linke "polygon". when i click "marker" i have the possibility to add markers do my map, if i click "polygon" i can add polygons to my map.
Greetings and thank you,
Ramo
i'm trying to figure out, how to set a marker programatoically via the pointSelectListener listener.
In my backing bean i used this code:
Code: Select all
public void onPointSelect(PointSelectEvent event) {
LatLng latlng = event.getLatLng();
Marker marker = new Marker(latlng);
model.addOverlay(marker);
addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Point and Marker selected and set", "Lat:" + latlng.getLat() + ", Lng:" + latlng.getLng()));
}
Code: Select all
<p:gmap center="41.381542, 2.122893" zoom="15" type="ROADMAP"
style="width:600px;height:400px" model="#{mapBean.model}"
stateChangeListener="#{mapBean.onStateChange}" onStateChangeUpdate="messages"
pointSelectListener="#{mapBean.onPointSelect}" onPointSelectUpdate="messages"
/>
Any hints? Is there a way, that i can even allow setting markers, or polygons via links? i mean one link "marker" the seconde linke "polygon". when i click "marker" i have the possibility to add markers do my map, if i click "polygon" i can add polygons to my map.
Greetings and thank you,
Ramo