i`ve got 2 Problems with my GMap. Im using Java Server Faces and
Richfaces, my map is displayed in xhtml-file. Everything works fine,
the markermanager too, except the funcition clearMarkers() does not
remove all of my markers. Would be nice if someone can have a look at
my code.
Second Problem - can i delete a map and re-initialize it? I`d like to
display 2 maps on one page, or recreate a complete new map on the
first ones position. When i do so, my browser is loading my xhtml-file
endlessly. When i abort hte loading of the page and press F5 i got the
correct display.
<script type="text/javascript">
//<![CDATA[
var mgr;
var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.shadow = "http://www.schlumsch.eu/e2e/gmapicons/ shadow50.png";
baseIcon.iconSize = new GSize(20, 34);
baseIcon.shadowSize = new GSize(37, 34);
baseIcon.iconAnchor = new GPoint(9, 34);
baseIcon.infoWindowAnchor = new GPoint(9, 2);
function clearMarkers() {
mgr.removeMarker(marker);
}
function setCenter(lag, lat, zoom) {
map2.setCenter(new GLatLng(lag, lat), zoom);
var ulp = new GPoint(lag,lat);
var ul = G_NORMAL_MAP.getProjection().fromPixelToLatLng(ulp,zoom);
}
function createPoints(data) {
for (var i = 0; data.length; i++) {
var point = new GLatLng(data[i].latitude, data[i].longitude);
map2.setCenter(point);
map2.setZoom(16);
map2.addOverlay(createMarkerWithIdentifier(point, data[i].id,
data[i].beschreibung));
}
}
function createMarkerWithIdentifier(point, id, beschreibung) {
mgr = new MarkerManager(map2, {trackMarkers:true});
var nummer = id;
var idIcon = new GIcon(baseIcon);
idIcon.image = "http://www.schlumsch.eu/e2e/gmapicons/marker" + id +
".png";
markerOptions = { icon:idIcon };
var marker = new GMarker(point, markerOptions);
mgr.addMarker(marker);
mgr.refresh();
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(beschreibung);
});
GEvent.addListener(marker, "dblclick", function()
{ mgr.removeMarker(marker); } );
On Sep 11, 6:55 am, schlumsch <schlum...@gmx.net> wrote:
> Hi all,
> i`ve got 2 Problems with my GMap. Im using Java Server Faces and
> Richfaces, my map is displayed in xhtml-file. Everything works fine,
> the markermanager too, except the funcition clearMarkers() does not
> remove all of my markers. Would be nice if someone can have a look at
> my code.
> Second Problem - can i delete a map and re-initialize it? I`d like to
> display 2 maps on one page, or recreate a complete new map on the
> first ones position. When i do so, my browser is loading my xhtml-file
> endlessly. When i abort hte loading of the page and press F5 i got the
> correct display.
The normal way to use MarkerManager is to have *one* MarkerManager instance to which you add lots of markers. If you do it that way, then you can write
function clearMarkers() { mgr.clearMarkers();
}
What your code does is create lots of MarkerManager instances, each of which handle one marker. Your "mgr" variable is a reference to the last MarkerManager that you created, so you can only make calls that affect the marker that that MarkerManager manages.
Well, i`m sorry but i dont have the possibility to link my code now.
So i have to post some code again.
When i define gmarkers and mgr global, no marker is shown on the map,
error: map2 is not defined.
When i define both in a function, for example in createpoints, no
error is produced but also no marker shown :)
var mgr = new MarkerManager(map2);
var markerlist = [];
function createPoints(data) {
for (var i = 0; data.length; i++) {
var point = new GLatLng(data[i].latitude, data[i].longitude);
map2.setCenter(point);
map2.setZoom(16);
map2.addOverlay(createMarkerWithIdentifier(point, data[i].id,
data[i].beschreibung));
}
mgr.addMarkers(markerlist);
mgr.refresh;
}
function createMarkerWithIdentifier(point, id, beschreibung) {
var nummer = id;
var idIcon = new GIcon(baseIcon);
idIcon.image = "http://www.schlumsch.eu/e2e/ gmapicons/marker" + id + ".png";
markerOptions = { icon:idIcon };
var marker = new GMarker(point, markerOptions);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(beschreibung);
});
GEvent.addListener(marker, "dblclick", function()
{ mgr.removeMarker(marker); } );
markerlist.push(marker);
So, can anybody tell me how to modify the above given code (sorry
again)? Even when i create lots of markermanagers like in my first
posting, the delete-link is not working. (should kill the last one) O
only the listener for doubleklick works fine...
thx & lg schlumsch
On 12 Sep., 20:30, Ralph Ames <ralph.a...@gmail.com> wrote: