Hello,
I am facing issue to remove marker from SimpleMarkerOverlay. also I have tried with creating new object of SimpleMarkerOverlay so that it will create a new instance of that and pass it to map. Also it pass new MapX and MapY coordinates but still it shows old marker on map.
I have used CloudPopup to show popup on map and bind that popup from client side on map. CloudPopup shows at proper place but issue is with Marker it shows still at the same position if I pass new MapX and MapY coordinates.
I am pasting my code.
WebImage wimage =
new
WebImage(Url.Content(
“ShapeFiles/Images/Locate.png”
));
wimage.ImageOffsetY = -30;
wimage.ImageOffsetX = -10;
SimpleMarkerOverlay markerOverlay =
new
SimpleMarkerOverlay(
“markerOverlay”
);
markerOverlay.OnClientClick =
“clickOnMarker”
;
Marker mrk =
new
Marker(ps, wimage);
mrk.IsVisible =
true
;
markerOverlay.Markers.Add(mrk);
map.CustomOverlays.Remove(
“markerOverlay”
);
map.CustomOverlays.Add(markerOverlay);
CloudPopup popup =
null
;
popup =
new
CloudPopup(
“Popup”
, ps, Content, width, height,
true
,
true
);
popup.IsVisible =
true
;
return
popup.ToJson();
And here is code on client side to call function to add Marker and call back function to add Popup on map.
function
ShowMarker(htmlcontent,pLon,pLat)
{
var
params = { lon: pLon, lat: pLat, content: htmlcontent };
Map1.ajaxCallAction(
‘Home’
,
‘AddMarker’
, params, mapCallback);
}
function
mapCallback(result) {
var
olMap = Map1.getOpenLayersMap();
for
(
var
i = 0; i < olMap.popups.length; i++) {
olMap.removePopup(olMap.popups);
}
var
jsonPopup = JSON.parse(result.get_responseData());
var
popupCreator =
new
Popup(jsonPopup,
null
);
olMap.addPopup(popupCreator.element,
true
);
Map1.redrawLayer(
“MarkerOverlay”
);
}
Please check the code and let me know if I made some mistake in this.
Thank you.