Я пытаюсь «нарисовать» овальную форму на Google Maps V3. Кажется, я не могу найти простой способ сделать это.Как нарисовать овальную форму на Google Maps V3?
В настоящий момент я делаю это, используя серию полигонов, но, как вы можете видеть из моего JSFIDDLE, делать это таким образом делает сложной задачей создание «гладкой» овальной формы.
Есть ли лучший способ сделать это?
Это то, что у меня есть на данный момент: -
/* Google Map - Areas we cover */
var center = new google.maps.LatLng(51.2576646,-0.3258271);
function initialize() {
var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
var isDraggable = w > 480 ? true : false;
var mapOptions = {
zoom: 7,
center: center,
scrollwheel: false,
draggable: isDraggable,
disableDefaultUI: true,
zoomControl: true
};
var map = new google.maps.Map(document.getElementById('areas'),
mapOptions);
var styles = [
{"featureType":"landscape.man_made","elementType":"geometry.fill","stylers":[{"saturation":"-63"},{"lightness":"23"}]},{"featureType":"landscape.natural","elementType":"geometry.fill","stylers":[{"saturation":"-100"},{"lightness":"25"}]},{"featureType":"landscape.natural.terrain","elementType":"geometry.fill","stylers":[{"saturation":"0"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"saturation":"0"},{"color":"#95bf97"},{"lightness":"59"}]},{"featureType":"poi.school","elementType":"geometry.fill","stylers":[{"lightness":"5"},{"hue":"#ff0000"},{"saturation":"-100"}]},{"featureType":"poi.sports_complex","elementType":"geometry.fill","stylers":[{"lightness":"5"},{"saturation":"-100"}]},{"featureType":"road.local","elementType":"geometry.fill","stylers":[{"saturation":"-85"},{"lightness":"12"}]}
];
// Areas Circle Polygon
var myCoordinates = [
new google.maps.LatLng(51.522416,-0.142822),
new google.maps.LatLng(51.426614,-0.845947),
new google.maps.LatLng(51.303145,-1.109619),
new google.maps.LatLng(51.110420,-1.252441),
new google.maps.LatLng(50.958427,-1.065674),
new google.maps.LatLng(50.833698,-0.681152),
new google.maps.LatLng(50.785102,-0.043945),
new google.maps.LatLng(50.840636,0.362549),
new google.maps.LatLng(50.965346,0.845947),
new google.maps.LatLng(51.110420,0.966797),
new google.maps.LatLng(51.296276,0.966797),
new google.maps.LatLng(51.412912,0.747070),
new google.maps.LatLng(51.522416,0.010986),
new google.maps.LatLng(51.522416,-0.109863)
];
var polyOptions = {
path: myCoordinates,
strokeColor: "#21509b",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#21509b",
fillOpacity: 0.3
}
var it = new google.maps.Polygon(polyOptions);
it.setMap(map);
map.setOptions({styles: styles});
}
initialize();
Возможный дубликат [Google maps - рисовать эллипс основан на 4 координатах] (http://stackoverflow.com/questions/13157880/google-maps-draw-ellipse-based-off-4-coordinates) – geocodezip