我有一个html表单,收集看起来像这样的变量:
ent1_label
ent2_label
ent1att1_label
ent1att2_label
ent2att1_label
ent2att2_label
ent1att1val1_label
ent1att1val2_label
...
ent2att2val2_label
Run Code Online (Sandbox Code Playgroud)
我事先并不知道有多少ent,att或val将从表单到动作脚本.在输入表单中,我运行连接变量名称的循环:
ent<cfoutput>#i#</cfoutput>att<cfoutput>#j#</cfoutput>val<cfoutput>#k#</cfoutput>_label
(where i, j, and k are the number of ent, att, and val)
Run Code Online (Sandbox Code Playgroud)
这在输入表单上效果很好,但后来我在动作脚本中如何引用它们时迷失了方向.
我玩过#form.fieldnames#,它包含所有实际的变量名.
<cfset #formfields# = listToArray(#form.fieldnames#, ",")>
<cfset #formlength# = arraylen(#formfields#)>
<cfset #entattval_label# = arrayNew(1)>
<cfloop from="1" to="#formlength#" index="i">
<cfif REfind("ENT[0-9]*ATT[0-9]*VAL[0-9]*_LABEL", #formfields[i]#) EQ 1>
<cfset arrayAppend(entattval_label, "#formfields[i]#")>
</cfif>
</cfloop>
Run Code Online (Sandbox Code Playgroud)
将为我需要的每个变量子集创建单独的数组.但是如何让它打印变量的内容而不是它们的名字呢?
<cfset #label_length# = arraylen(#entattval_label#)>
<cfloop from="1" to="#label_length#" index="i">
<cfoutput>#entattval_label[i]#</cfoutput>
</cfloop>
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试为我的一个大学项目编写一个简单的网络应用程序原型。我对 Javascript 还很陌生,但遇到了一些麻烦。
我创建了一个地图,在用户的当前位置放置一个标记,并在一个固定点放置一个标记。这是到目前为止的Javascript:
var map;
function load() {
var myOptions = {
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map"), myOptions);
navigator.geolocation.getCurrentPosition(displayOnMap);
}
var pin;
function displayOnMap(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
var initialLocation = new google.maps.LatLng(latitude, longitude);
map.setCenter(initialLocation);
var marker = new google.maps.Marker({
map: map,
position: initialLocation,
});
loadMarkers();
}
function loadMarkers() {
var xmlMarkersRequest = new XMLHttpRequest();
xmlMarkersRequest.onreadystatechange = function() {
if (xmlMarkersRequest.readyState === 4) {
var xml = xmlMarkersRequest.responseXML;
var markersArray …Run Code Online (Sandbox Code Playgroud)我正在使用Yeoman webapp生成器(https://github.com/yeoman/generator-webapp),我已经添加了Bower包GMAPS(https://github.com/hpneo/gmaps).将Gmaps添加到我的项目后,我在项目的顶部添加了Google Api链接
<!-- build:css(.tmp) styles/main.css -->
<script src="http://maps.google.com/maps/api/js?sensor=true"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用Grunt Serve命令时,我看到我的Gmaps出现在我的本地主机上运行的网站上.如果我Grunt构建我的项目它总是给我一个错误,在我的main.js文件中它找不到变量Gmaps(用于触发Gmaps插件).
所以我的问题是:如何将API添加到使用Grunt构建的项目中?
我正在对Google地图进行一些实验,我的目标是在地图上放置标记,这取决于它何时被拖动或调整大小,所以我打算使用"空闲"事件监听器.问题是我无法让它发挥作用.
我在空闲侦听器中放置一个警告框来测试它,但它不会被触发.这是我到目前为止:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=true"></script>
<script>
var map;
var geocoder;
var markers = [];
function initialize()
{
var myOptions = {
center: new google.maps.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>),
zoom: 12,
mapTypeId: google.maps.MapTypeId.ROADMAP,
panControl: true,
zoomControl: true,
scaleControl: true
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
//regenerateMarkers(); // 29/7/15
}
// Initializes the Google Map
google.maps.event.addDomListener(window, 'load', initialize);
google.maps.event.addListener(map, 'idle', function() {
//regenerateMarkers(); // 29/7/15
alert("inside idle");
});
</script>
Run Code Online (Sandbox Code Playgroud)
显示地图的html如下:
<div id="map_canvas" style="height: 450px; width: 900px;"></div>
Run Code Online (Sandbox Code Playgroud)
我不能为我的生活看到为什么空闲的听众没有开火提起警报箱.有人可以帮忙吗?非常感谢!
我为附近的美食广场创建了谷歌地图.在这个标记显示在浏览器中并可点击并给出信息窗口数据.但同样的东西来到移动,标记显示,当点击标记(点击标记)信息窗口数据不显示.我尝试了这么多论坛和改变了很多代码和调试,但我找不到解决方案.
foodFactory.js
var foodModule = angular.module('foodModule', []);
foodModule.factory("foodFactory", ['$rootScope', '$window','foodServices', 'localStorageService', '$state', '$ionicLoading','$stateParams',
function($rootScope, $window, foodServices, localStorageService, $state, $ionicLoading, $stateParams, $cordovaGeolocation ) {
var foodCourtmap = {};
var marker = {};
var directionsDisplay = new google.maps.DirectionsRenderer({'draggable': true });
var directionsService = new google.maps.DirectionsService();
foodCourtmap.centerOnMe = function() {
initialize();
};
//intialze the google map it's show current location.
function initialize() {
var infowindow = new google.maps.InfoWindow();
navigator.geolocation.getCurrentPosition(function(pos) {
foodCourtmap.latitude = pos.coords.latitude;
foodCourtmap.longitude = pos.coords.longitude;
var …Run Code Online (Sandbox Code Playgroud) Requerment是在谷歌地图上使用多个路点在起始位置和结束位置之间绘制路径.路径很好,但问题是坐标之间有几条直线.如何删除坐标之外的额外直线?
我的代码如下
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var markers = [
{
"title": 'A',
"lat": '26.3489',
"lng": ' 92.6845',
"description": 'A'
}
,
{
"title": 'B',
"lat": '26.3546',
"lng": '92.6902',
"description": 'B'
}
,
{
"title": 'D',
"lat": '26.3508',
"lng": '92.7102',
"description": 'D'
}
,
{
"title": 'E',
"lat": '26.4285',
"lng": '92.8497',
"description": 'E'
}
,
{
"title": 'E',
"lat": '26.5486',
"lng": '92.9008',
"description": 'E'
}
,
{
"title": 'E',
"lat": ' 26.6567',
"lng": '92.7717',
"description": 'E'
}
,
{ …Run Code Online (Sandbox Code Playgroud) google-maps ×4
javascript ×4
angularjs ×1
bower ×1
coldfusion ×1
geolocation ×1
gruntjs ×1
infowindow ×1
ionic ×1
regex ×1
yeoman ×1