I have seen API calls that do not use the Import Library method.
Like:
cityCircle = new google.maps.Circle(sunCircle);
cityCircle.bindTo('center', marker, 'position');
But I am using the Import Library.
Everything else works in my code but the circle.
I get Error: The library circle is unknown.
I follow the link it recommends. I do not know whether to use drawing or geometery.
Using the search on api documentation for circle radius never shows anything involving importing library.
I appreciate any guidance.
My Code that creates the PIN. This is inside an object ModGPS (attempting some resemblance To OOP.)
PinIt : async function ( sComp, sName, nLat, nLon, nRadius, sFunc = 'PinIt' )
{
if ( ModGPS.debug ) console.log( ModGPS.Object + ' ' + sFunc + '()' ) ;
const { Map } = await google.maps.importLibrary( "maps" ) ;
const { Marker } = await google.maps.importLibrary( "marker" ) ;
const { Circle } = await google.maps.importLibrary( "circle" ) ;
let oPosition = { lat : nLat, lng : nLon, } ;
let oCoord =
{
zoom : 18,
center : oPosition ,
mapId : 'Company_Properties',
} ;
let NewMap = new Map( ModGPS.dom.Map, oCoord ) ;
let sDisplay = ".n n " + sComp + " " + sName + " n n." ;
const marker = new Marker( { map : NewMap, position : oPosition, title : sDisplay, } ) ;
const circle = new Circle(
{
strokeColor : "#FF0000",
strokeOpacity : 0.8,
strokeWeight : 2,
fillColor : "#FF0000",
fillOpacity : 0.35,
NewMap,
center : oPosition,
radius : nRadius,
}
) ;
},
2
Answers
Thank you Yrll. This Helped.
After adding the colors, the final product is spot on!
The final code I scripted with the help you provided:
The
Circle
class is still within the"maps"
libraryThere’s no such thing as
"circle"
library in the API. As I can see in your code, you are trying to import theCircle
class in this way:Please note that there’s nothing on the official documentation which says that this is how you import the
Circle
class.If you go to the Circle Class section in the Reference Documentation, you can access the class by calling,
This means that the
Circle
class is still included within the"maps"
core library. And that the"circle"
library you used as an argument to.importLibrary
is non-existent as described by the error you encountered:Error: The library circle is unknown
Here’s a sample code snippet for you to see it working fine with the mentioned solution above:
I hope this helps!