Copy link to clipboard
Copied
Hello,
I have a Google Map embedded in my website using cfmap. I would like to "lock" the map location, or disable panning so the user can not move where the map is centered. Is this possible using cfmap? I have tried to use the disableDragging() javascript function with no luck...any suggestions?
<cfoutput>
<cfmap centeraddress="#lat#, #long#" width="400" height="400" zoomLevel="18" type="hybrid" scrollwheelzoom="false" showCenterMarker="false" overview = "false" >
<cfloop query="mrs2">
<cfmapitem latitude="#lat#"
longitude="#long#"
tip="#POINT_NAME#">
</cfloop>
</cfmap>
</cfoutput>
Thanks!
Copy link to clipboard
Copied
Interesting. I don't think one can do it with CFMAP.
It might be worth raising an enhacement request of Adobe:
http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html
And then look throught eh Google API, as I am sure there'll be a way to do it (I shall research this myself...)
--
Adam
Copy link to clipboard
Copied
I consulted with my resident Google maps expert, and he pointed me to this:
http://code.google.com/apis/maps/documentation/javascript/reference.html#MapOptions
Which looks like stuff you've already read. He was bemused at why the disableDragging thing didn't work for you.
Could you produce some self-contained and stand-alone code that shows how you were trying this? I'll give me something to go on.
He also pointed me to this:
http://code.google.com/apis/maps/documentation/staticmaps/
That could be an option? Possibly too restrictive for what you want.
--
Adam
Copy link to clipboard
Copied
Here is my code for the whole page. I am not a javascript expert, so I am sure I am doing something wrong with the disableDragging() function. I am just confused on how to integrate the cf and javascript together in this instance.
Thanks for your help!!!
function initialize() {
var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
map.disableDragging();
}
});
}
<body topmargin=10 leftmargin=10 <!-onLoad="window.resizeTo(1280,1024)"->>
</html
Copy link to clipboard
Copied
Can you post that code again? It got kinda munged.
I dunno if you're emailing your responses in (as opposed to using the forum's web-based UI), but if you are... you're gonna struggle to post code. However using the web UI it usually doesn't mess with code copy & pasted into a reply.
But these forums do have a mind of their own.
--
Adam
Copy link to clipboard
Copied
Oh, and PLEASE don't post the entire page. Just post the relevant code, which should be this:
1) the CFMAP call
2) the JS you are applying to the CFMAP call.
And the code you paste shoudl eb self-contained so I (or anyone else that's wanting to help) can copy & paste it into a file and run it and see what you'r seeing.
--
Adam
Copy link to clipboard
Copied
Sorry about that Adam. Here are the relevant pieces code. I know the javascript part is not correct, but it is all I have at the moment:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
</script>
function initialize() {
var map = new GMap2(document.getElementById('map'));
// disable map dragging
map.disableDragging();
}
<cfoutput>
<cfmap centeraddress="#lat#, #long#" width="400" height="400" zoomLevel="18" type="hybrid" scrollwheelzoom="false" showCenterMarker="false" overview = "false" >
<cfloop query="mrs2">
<cfmapitem latitude="#lat#"
longitude="#long#"
tip="#POINT_NAME#">
</cfloop>
</cfmap>
</cfoutput>
Copy link to clipboard
Copied
Hi Emily.
I haven't forgotten about this. I could get the disableDragging() method to work, but not onload, only when clicking a link to execute the call. It's something to do with how CFMAP pulls in the google stuff I think. I tried using JQuery's document-ready approach but I still could not access the CF wrapper object for the map. I'm not beaten yet though.
That said, perhaps it'd just be quicker and easier to just do it all with the Google API entirely, rather than a hybrid of CF & Google API. CF's version of the API is obsolete, for one thing.
There's an easy-to-follow tutorial here: http://marcgrabanski.com/articles/jquery-google-maps-tutorial-basics
I'll report back if/when I crack it with CFMAP.
--
Adam
Copy link to clipboard
Copied
Thanks again Adam.
I am using Coldfusion to pass variables for the latitude and longitude of the Google point location. I will follow the tutorial and see if this is possible using the Google API.
I appreciate your time and effort on this:)
Copy link to clipboard
Copied
Hi Emily.
Let us know how you get on with using the API.
I spent a fair chunk of Saturday evening trying to get CFMAP to play nice with the disableDragging() method, but drew a complete blank. It seemed to me that CF was forcing its own code JS code to run absolutely last, which meant the disableDragging() call was applied first, then CF put the map in the div after it (and basically resetting that setting). This is probably a reflection of my mediocre capabilities with JS & JQuery as much as anything else.
So I've drawn a blank, and I give up, I'm afraid.
I am keen to see your eventual solution though, when you come up with it.
Cheers.
--
Adam
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more