谷歌地图v3中getVertexCount()的替换是什么?请告诉我。我在我的代码中使用了相同的v3,但它似乎没有工作。在v3中是否有替换getVertexCount()或没有强制替换?如果有,请让我知道更换功能。我提供了我的version2代码的initialize()函数。请建议。以下是我的第2版代码的初始化函数:
function initialize() {
if (GBrowserIsCompatible()) {
// Initialize geocoder for address search
geocoder = new GClientGeocoder();
// Draw the map
var startPoint = parseCoordinate(VALUE_SITE_COORDINATE);
map = new GMap2(document.getElementById(ID_DIV_MAP_CANVAS));
map.setCenter(startPoint, 13);
map.setUIToDefault();
// Listener for map mouse move event showing pointer coordinates
GEvent.addListener(map, 'mousemove', function(latlng) {
document.getElementById(ID_INPUT_CURRENT_COORDINATE).value = latlng;
});
// Draw the main polygon
var coordinates = parseCoordinates(VALUE_COORDINATES);
if( coordinates.length > 0)
{
polygon = createPolygonOnInit(coordinates);
map.addOverlay(polygon);
if (polygon.getVertexCount() == MAX_VERTICES_RECTANGLE) {
createBackgroundPolygon();
}
adjustMapAppearance(map);
}
// Render polygon coordinates
showCoordinates(coordinates);
// Create our "tiny" marker icon
var blueIcon = new GIcon(G_DEFAULT_ICON);
blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
// Set up our GMarkerOptions object
markerOptions = { icon:blueIcon };
map.addOverlay(new GMarker(startPoint, markerOptions));
// Set initial state
if (coordinates.length == 0) {
setState(STATE_NO_GEO_FENCE);
} else {
setState(STATE_READ_GEO_FENCE);
prevstate = STATE_READ_GEO_FENCE;
}
}
}
答案 0 :(得分:0)
因此...
假设您已设法将所有其余代码重写为v3(如果是这样,它也有助于将其添加到您的问题中),并且您只需要计算最后一位以检查顶点),你可以尝试:
path = polygon.getPath();
if (path.getLength() == MAX_VERTICES_RECTANGLE) {