I'm going to guess the problem is that the js is seeing your object as a
string.
I *think* this would work. Can't say for sure without testing it. I can
never remember weather you can use this.value with a select and have it
work. You may need to change it
to this.options[this.selectedIndex].value.split('|')[0] to target the value.
<select name="location"
onChange="ColdFusion.Map.setCenter('map1',{latitude:this.value.split('|')[0],longitude:this.value.split('|')[1]};ColdFusion.Map.setZoomLevel('map1',10);">
<option>Select Location</option>
<cfloop query="getMapLocations"><option
value="#getMapLocations.latitude#|#getMapLocations.longitude#">#getMapLocations.name#</option></cfloop>
</select>
On Tue, Jul 6, 2010 at 8:09 AM, Pete Ruckelshaus <[email protected]>wrote:
>
> I'm having a bit of trouble getting some JavaScript working with CFMAP. I
> currently use a link to center the map and zoom in on a specific location;
> this code works fine:
>
> <a
>
> href="javascript:ColdFusion.Map.setCenter('map1',{latitude:#getMapLocations.latitude#,longitude:#getMapLocations.longitude#});javascript:ColdFusion.Map.setZoomLevel('map1',10);">Zoom</a>
>
> Due to the number of locations on the map, I want to provide users with a
> way of selecting a location from a dropdown list, and then having the map
> zoom and center on the selected location using an onchange event handler in
> the select tag. I feel like this would work, but it doesn't:
>
> <form>
> <select name="location" onChange="ColdFusion.Map.setCenter('map1',
>
> this.options[this.selectedIndex].value);ColdFusion.Map.setZoomLevel('map1',10);">
> <option>Select Location</option>
> <cfloop query="getMapLocations"><option
>
> value="{latitude:#getMapLocations.latitude#,longitude:#getMapLocations.longitude#}">#getMapLocations.name#</option>
> </cfloop>
> </select>
> </form>
>
> The error that I'm getting is:
>
> Uncaught ColdFusion.Map.setCenter: center should be a textual address or
> latitude/longitude pair, id: map1
>
> Any ideas?
>
> Thanks,
>
> Pete
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335095
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm