Custom Google Maps polygon with background image and hover effect

Is it possible to create a webapp using the Google V3 Maps API, which uses custom images for countries or regions that change when you hover over the mouse and mouse?

I looked at google.maps.GroundOverlay and ProjectedOverlay, but did not find a solution. An example would also be great. Thanks.

+4
source share
1 answer

Yes, maybe ... there are several ways to do this

One way is to use OverlayView - see a demo here Show / hide overlays

From the documentation :

  • Define a custom object prototype for the new google.maps.OverlayView () instance. This will effectively β€œsubclass” the overlay class.
  • Create a constructor for the custom overlay and set any initialization parameters for the custom properties inside this constructor.
  • Embed the onAdd () method in your prototype and attach the overlay to the map. OverlayView.onAdd () will be called when the map is ready to attach the overlay.
  • Embed the draw () method in your prototype and handle the visual display of your object. OverlayView.draw () is called when the object is first displayed.
  • You must also implement the onRemove () method to clear any elements added to the overlay.

After that, you will need to add eventListener to the map for the click event, for example, to activate this OverlayView, here is an example of how to add clickListener click on the map <a2>

0
source

Source: https://habr.com/ru/post/1480448/


All Articles