Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create circle in google map v3 with same radius in all zoom level?

Tags:

I am working on map code migration from v2 to v3.

In v2 i have create circle with help of GProjection and Overlay and it will look same size in all zoom level.

In v3 google gives Circle class that will create circle in map but it will change in different zoom level.

I want to create circle that will have same size in all zoom level.

I want to know any other way in google map v3 by that i can create circle with same size for all zoom level.

Thanks in advance.

like image 245
Ashvin Avatar asked Jul 23 '12 18:07

Ashvin


People also ask

How do you draw a radius circle on Google Maps?

We found two handy tools that you can use to draw a radius on your map. One is CalcMaps, and the other one is Maps.ie. If you're using CalcMaps, click on Draw a circle and add the circle on the map area you're interested in. Use can then use the drop-down menu to select the radius type you want to use.

How do you zoom all the way in on Google Maps?

Zoom in the mapDouble tap a spot on the map, and then: Drag down to zoom in. Drag up to zoom out.

How do you change the radius of a Google map?

Click on the map and create a popup marker to select the point. From there, opt for the “Draw Radius.” Choose the proximity distance from the given address found within the radius options in the software. Once settings are entered, a map will show the highlighted parameters on the map.

How do I draw a radius in Google?

Drawing the RadiusSelect the radius and proximity tool from the left-hand menu. Depending on your needs, choose either distance radius or drive time polygon. Enter your locations and the distance you would like your radius to reach from the center point. Customize your map with color-coding and labeling tools.


2 Answers

To create circles that are the same pixel size on the screen (versus same area size in geographic coordinates), you would traditionally use a Marker with a custom Icon in the shape of a circle. But now you can be more flexible and use the relatively new Symbols in v3.

var marker = new google.maps.Marker({   position: new google.maps.LatLng(-122.5,47.5),   icon: {     path: google.maps.SymbolPath.CIRCLE,     fillOpacity: 0.5,     fillColor: '#ff0000',     strokeOpacity: 1.0,     strokeColor: '#fff000',     strokeWeight: 3.0,      scale: 20 //pixels   } }); 

Aside: You can make cool animations out of these symbols as well: http://googlegeodevelopers.blogspot.com/2012/06/powerful-data-visualization-with.html

like image 69
jlivni Avatar answered Sep 18 '22 17:09

jlivni


I use this code to manage zoom and scaling circles on my Google Map V3:

google.maps.event.addListener(iMap.map, 'zoom_changed', function () {     for (var i = 0; i < iMap.circle.length; i++) {         var p = Math.pow(2, (21 - iMap.map.getZoom()));         iMap.circle[i].setRadius(p * 1128.497220 * 0.0027);     }      menu.hide(); }); 
like image 35
Ramin Farajpour Avatar answered Sep 17 '22 17:09

Ramin Farajpour