Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing Circles instead of Markers in google maps

I would like to add 2 circles(red and green) instead of the default marker on the google maps. I need the color of the circles to change(increase/decrease of intensity) based on the values in the database. Is it possible to do so?

like image 922
user3844966 Avatar asked Nov 28 '22 23:11

user3844966


1 Answers

Create a circle as a marker icon, for example:

var oMarker = new google.maps.Marker({
    position: latLng,
    sName: "Marker Name",
    map: map,
    icon: {
        path: google.maps.SymbolPath.CIRCLE,
        scale: 8.5,
        fillColor: "#F00",
        fillOpacity: 0.4,
        strokeWeight: 0.4
    },
});

and then, if you want to change the marker dynamically (like on mouseover), you can, for example:

oMarker.setIcon({
            path: google.maps.SymbolPath.CIRCLE,
            scale: 10,
            fillColor: "#0F0",
            fillOpacity: 0.8,
            strokeWeight: 1
        })
like image 127
Roman Avatar answered Dec 01 '22 14:12

Roman