JS/Regex -删除周围的括号;中心标记(CloudMade Maps)
JS/Regex - Remove surrounding parenthesis; Center marker (CloudMade Maps)
我是一个编程新手,所以到目前为止我所看到的示例对于我的代码来说太难采用了。我有一个地图,上面有一个文本框,显示地图的当前中心坐标。中心坐标被完美地获取,但由于某种原因,它们周围有括号。我需要在提交输入字段的表单之前删除这些括号。
<div id="coordinates"></div>
<div id="map" style="width:750px;height:400px;">
<script type="text/javascript" src="http://tile.cloudmade.com/wml/latest/web-maps-lite.js"></script>
<script type="text/javascript">
var cloudmade = new CM.Tiles.CloudMade.Web({key: 'YOUR KEY HERE'});
var map = new CM.Map('map', cloudmade);
map.setCenter(new CM.LatLng(38.27269,-92.46094), 4);
var currentLatLng = map.getCenter;
var myMarkerLatLng = new CM.LatLng(38.27269,-92.46094);
var myMarker = new CM.Marker(myMarkerLatLng, {title: "Search a 12-mile radius around this marker..."});
map.addOverlay(myMarker);
CM.Event.addListener(map, 'dragend', function() {
document.getElementById("coordinates").innerHTML = "<input onclick='cleanString();' type='text' name='lat' value='" + map.getCenter().toString(6) + "' />";
});
CM.Event.addListener(map, 'moveend', function() {
document.getElementById("coordinates").innerHTML = "<input type='text' name='lat' value='" + map.getCenter().toString(6) + "' />";
});
</script>
谢谢你的帮助:)
map.getCenter().toString(6).match(/[^()]+/)
就圆括号而言。但记号笔的事我帮不了你。当我把你的网站放在jsfiddle我得到一堆"状态403禁止"的错误。
基本上上面的代码使用了一个正则表达式match
表达式。它是"一个或多个(+
)非括号([^()]
^符号是not
)字符([]
表示字符集)的匹配"。
相关文章:
- 单击超链接时,如何使用Google Maps API v3缩放地图
- 使用Google Maps API向标记添加多个字符
- Google Maps API OverlayView()在AngularJS指令中不起作用
- 使用Google Maps API驱动时间多边形
- 使用Google Maps JavaScript API v3和Geocoding API映射多个位置
- 在for循环中使用多维数组设置google.maps.Marker图标
- 可扩展的画布作为Google Maps Javascript API中的覆盖
- 在自动完成中使用Google Maps Places API;API不工作
- 如何在Maps API v3.中更改多段线的路径
- google.maps.event.addDomListener(window, 'load', fun
- 根据PHP中数组的长度在Google Maps API中循环遍历标记
- 加载Google MAPS API v3的JSON数据
- 如何使用Dojo引用Google Maps事件中的包含类
- Javascript:Google Maps API:如果地图加载在隐藏容器中,则为空白地图
- 如何在Ionic/Codova应用程序中保护我的Google Maps Javascript V3 API密钥
- 来自JSON数组的Google Maps API生成器
- Google Maps JavaScript API v3:getDetails(请求,回调),用于多个位置
- "现代的“;在Google Maps JS API v3上使用字母标记
- 在映射空闲时调用maps.getBounds()为null
- JS/Regex -删除周围的括号;中心标记(CloudMade Maps)