我正在使用google maps v3 API创建地图.使用绘图管理器绘制形状.有没有办法在绘制1个多边形后禁用多边形按钮?我一直在阅读API,但找不到多边形启动的任何事件,仅用于polygoncomplete.
也许是一种检测绘图模式变化的方法?或删除google.maps.drawing.OverlayType.POLYGON,但如果当前多边形被删除则将其放回去?
由于谷歌地图api v3不支持多边形或折线的开始或结束编辑,我正在尝试构建我自己的一个.
我正在为每个点绘制标记,然后完成编辑我在单击第一个索引点("0")时将所有标记设置为隐藏,然后将多边形设置为clickable为true.但是用户仍然可以单击地图并继续绘制多边形.我想禁用该事件监听器,但在鼠标悬停时重新启用它.可以这样做吗?如果我使用Remove Listener,我可以在鼠标悬停时将另一个侦听器重新连接到多边形,以便他们可以编辑吗?
MapShaper.Feature.prototype.poly = function(type) {
var color = MapShaper.getColor(false),
path = new google.maps.MVCArray,
poly,
self = this,
el = type + "_b";
if(type=="shape"){
poly = self.createShape( {strokeWeight: 3, fillColor: color}, path );
}else if(type=="line"){
poly = self.createLine( {strokeWeight: 3, strokeColor: color }, path );
}
poly.markers = new google.maps.MVCArray;
google.maps.event.addListener(poly, "mouseover", function(){
poly.markers.forEach(function(polyMarker, index){
polyMarker.setVisible(true);
});
});
MapShaper.Feature.prototype.createShape = function(opts, path) {
var poly;
poly = new google.maps.Polygon({
clickable:false,
strokeWeight: opts.strokeWeight,
fillColor: opts.fillColor
});
poly.setPaths(new google.maps.MVCArray([path]));
return …Run Code Online (Sandbox Code Playgroud) 我正在使用一个为谷歌地图编码多边形的 MySQL 数据库。当我尝试将查询作为 json 返回时,jsonlint 抱怨......我不知道它为什么抱怨,我确实尝试在 latlon 中转义“}”,但仍然遇到相同的错误。
第 20 行解析错误:
... "latlon": "}ciuF|a|pNcUr@d@es@
-----------------------^
期待 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
我的 json 是:
{
“地图”:[
{
"group_id": "0",
"user_id": "113",
“团队名字”: ””,
“笔记”: ””,
"field_id": "",
"field_name": "西牧场",
"field_notes": "",
"date_created": "12/31/2012",
“英亩”:“”
}
],
“多边形”:[
{
"polygon_id": "",
"field_id": "1",
"英亩": "92",
"latlon": "}ciuF|a|pNcUr@d@es@fIHXaNtCn@UxCjMlApAfFuBpI}E\ChJdEl@xAtE"
}
]
}
我正在使用react-select构建一个可重用的组件来选择美国州。我试图传递一个州值(如“OH”)来设置默认值,但似乎无法理解这一点。
我的数据(小样本):
const statesJson = [
{
"label": "Alabama",
"value": "AL"
},
{
"label": "Alaska",
"value": "AK"
},
{
"label": "American Samoa",
"value": "AS"
},
{
"label": "Arizona",
"value": "AZ"
},
{
"label": "Ohio",
"value": "OH"
}
]
Run Code Online (Sandbox Code Playgroud)
我的组件:
import React, { Fragment, useState} from "react";
import statesJson from "./states";
import Select, { components } from "react-select";
import styled from "styled-components";
import PropTypes from "prop-types";
const StyledSelect = styled(Select)`
font-size: 16px;
font-weight: normal;
color: #041e41;
width: 250px;
`;
const propTypes …Run Code Online (Sandbox Code Playgroud) 我注意到在使用绘图管理器绘制多边形时它们没有关闭(即最后一个点到第一个点没有坐标)。我知道 Google Maps API v3 会自动关闭多边形但是 Google Earth、Google Static Maps API 或任何其他软件我尝试将数据导入..
我的问题是,我使用几何库来保存编码的多边形.. 有没有办法在编码之前将第一个点的副本推送到叠加对象中的最后一个点?
我的解决方法是将 getPaths().getArray() 复制到我自己的数组中,然后进行复制,然后使用 javascript lib 进行编码,这可以正常工作,但是代码很多.. 只是想知道是否有更简单的方法?
我试着在google maps v3中找出MVCArray().我使用GeoJason编写的代码作为示例.我将一个click事件附加到标记以获取其LatLng位置.它运作良好,但如果将标记拖动到新位置,我需要在新位置更新MVCArray.这部分让我难过..任何人都知道如何做到这一点或者能指出一个很好的资源,解释使用MVCArray的?(除了coode docs,它不是为新手设计的..大声笑)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>GeoJason - Line Length and Polygon Area with Google Maps API v3 Demo</title>
<meta name="keywords" content="" />
<meta name="description" content="Demo of how to get Line Length and Polygon Area with Google Maps API v3" />
<link rel="stylesheet" type="text/css" href="style/default.css" />
<!-- Script -->
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript" src="js/jquery/jquery-1.4.2.js"></script>
<script type="text/javascript">
var map;
var markerImageDefault = new google.maps.MarkerImage('images/markers/measure-vertex.png',null, …Run Code Online (Sandbox Code Playgroud) 我已经从Github 添加了一个Tealium AngularJS lib作为我的SPA的凉亭组件.这立刻打破了我的单元测试.我不明白为什么它仍然应该使用index.html已经设置了基本href 的主文件?
当我从命令行运行时gulp test,我收到此错误:
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 11 of 118 SUCCESS (0 secs / 0.721 secs)
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 12 of 118 SUCCESS (0 secs / 0.73
secs)
PhantomJS 1.9.8 (Windows 7 0.0.0): Executed 13 of 118 SUCCESS (0 secs / 0.741 secs)
PhantomJS 1.9.8 (Windows 7 0.0.0) ERROR
Error: [$location:noc:/dev/code/new-site-ui] $location in HTML5 mode requires a <c:/dev/code/new-site-ui> tag to be present!
http://errors.angularjs.org/1.4.8/$location/noc:/dev/code/new-site-ui
at c:/dev/code/new-site-ui/bower_components/angular/angular.js:12197
PhantomJS …Run Code Online (Sandbox Code Playgroud) google-maps ×4
javascript ×2
angularjs ×1
dom-events ×1
html5 ×1
json ×1
php ×1
react-select ×1
reactjs ×1
string ×1