I want build a zoom functionality when anyone clicks on a map. To do that I need to get X & Y coordinates of mouse cursor just when user click on the map.
I have seen that "Map GUI" do that in "marker definition tab" (FusionMapsGUI.html). This is is the code:
- - - - - - - - - - - - - - - - - - - - -
//If the user has switched to marker definition tab, we need to set
//map to choose mode.
if (i==2){
mapGUI.enableChooseMode();
}else{
mapGUI.disableChooseMode();
}
...
function registerMarker(x,y){
//This method is invoked when the user registers a marker on the chart.
//If X <0 or Y<0, we show appropriate message to user
if (x<0 || y<0){
window.alert("You can define Markers only within the map bounds. Please click within the red rectangle in the map to define Markers.");
return true;
}else{
//Show the marker pop up window
var wM = window.open('Resources/MarkerForm.html','MarkerSelectWin','width=450,height=225,scrollbars=0,toolbars=no,menu=no,status=1');
//Proxy X and Y data
wM.x = String(x);
wM.y = String(y);
//Pass markers array for duplicate check
wM.markerList = mapGUI.getMarkers();
wM.focus();
//Update flag
markerWinOpened = true;
return true;
}
}
- - - - - - - - - - - - - - - - - - - - -
Well, I'm trying to develope something like that, but this does not work. I get this error (translated to english): "object doesn't accept this property or method". Can you help me to solve than? Do you have sample code for this functionality? Thanks in advance.
This is my code:
-----------------
var map = new FusionMaps("FCMap_SpainProvinces.swf", "Map_Id", "560", "400", "0", "1");
map.setDataURL("data.xml");
map.render("mapDiv1");
enableChooseMode();
...
function enableChooseMode(){
/* var mapaObj = getMapFromId("Map_Id"); */
var mapaObj = infosoftglobal.FusionMapsUtil.getMapObject("Map_Id")
mapaObj.enableChooseMode(); /* <<<< HERE I GET ERROR */
return true;
}
function registerMarker(x,y){
//This method is invoked when the user registers a marker on the chart.
//If X <0 or Y<0, we show appropriate message to user
if (x<0 || y<0){
window.alert("You can define Markers only within the map bounds. Please click within the red rectangle in the map to define Markers.");
return true;
}else{
//Set values in Entry fields
document.getElementById('IdX').value = X;
document.getElementById('IdY').value = Y;
return true;
}
}