Guide to Incorporating a Marker into an SVG Blinking Rectangular or Circular Border Image on Google Maps

I have a link that points to a specific location on Google Maps using latitude and longitude:

http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png

Now, I am looking to add a blinking border to this marker link.

Is there a way to achieve this effect using HTML, CSS, or jQuery?

I have already implemented the marker link in a jsfiddle example.

If possible, please provide me with a jsfiddle link for reference.

How can I add a border that blinks around this marker using CSS, HTML, and jQuery?

Below is my code snippet for Google Maps:

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>Google Maps Multiple Markers</title> 
  <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
    </head> 
<body>
  <div id="map" style="width: 1000px; height: 600px;"></div>

  <script type="text/javascript">
    var locations = [
                            ['STHOWBGA01_ATIF_RNID_L015',24.31026,93.56268],
                            ['GWTRGOK004_BILF_RNOD_L023',23.70692,91.27397],
                            ['GWTRBLWBN1_BILF_RNOD_L038',24.0179,91.4529],
                            ['SJOWKHL007_ATIF_RNOD_L012',25.35197,92.3723],
                            ['TTINNMSAI4_VIOF_RNID_L011',27.66616,95.87926],
                            ['SIMWUKHRL5_VIOF_RNID_L061',25.12267,94.36558],
                            ['SDIMZLUKI3_BILF_RNOD_L035',25.63658,93.64943]

            ];

    var lat_center = 24.31026,
        long_center = 93.56268;

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 10,
      center: new google.maps.LatLng(lat_center, long_center),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    var marker, i, text;

    for (i = 0; i < locations.length; i++) {  

      marker = new google.maps.Marker({
          position: new google.maps.LatLng(locations[i][3], locations[i][2]),
          map: map
      });

      text = locations[i][0];

      if(locations[i][4] === lat_center && locations[i][2] === long_center) {

          marker.setAnimation(google.maps.Animation.DROP);
          marker.setIcon('http://maps.google.com/mapfiles/arrow.png ');
        //text += '<br>' + 'Additionl text for centered marker';
      }

      google.maps.event.addListener(marker, 'mouseover', (function(marker, text) {
        return function() {
          infowindow.setContent(text);
          infowindow.open(map, marker);
        }
      })(marker, text));
    }

  </script>
</body>
</html>

I want to modify the marker icon for the central point at coordinates lat_center and long_center by changing marker.setIcon.

Can multiple markers be customized with different icons in Google Maps?

Answer №1

http://jsfiddle.net/Muthukumaru/n4d80zLd - Link to the jsfiddle page

Embed the SVG code to display a custom marker

<svg class="marker" style="left: 300.779px; top: 95.16px;" height="66" width="66">
    <circle cy="33" cx="33" class="mark" r="25">
       <set id="show" attributeName="visibility" attributeType="CSS" to="visible"
         begin="0s; hide.end" dur="1s" fill="freeze"/>

        <set id="hide" attributeName="visibility" attributeType="CSS" to="hidden"
         begin="show.end" dur="1s" fill="freeze"/>
     </circle>

   <image x="18" y="-5" width="30" height="80"
     xlink:href="http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png" />     
 </svg>

Add border CSS for the marker

.mark{
    fill: none;
stroke: #FF9100;
stroke-width: 1px;
cursor: pointer;
z-index: 1000;
}

Answer №2

Take a look at the following code snippet:

HTML:

  <style type="text/css>
    .with_border {
       border:2px solid red;
     }
   </style>

  <div>

<p>Click on the image to make it blink</p>

<img id="border_icon" onclick="show()" class="" src="http://www.google.com/intl/en_us/mapfiles/ms/micons/red-dot.png">


 </div>

Include this javascript with JQUERY:

<script type="text/javascript">
    var blinkRate=500;

    function removeBorder(){
       $("#border_icon").removeClass("with_border");
       setTimeout(showBorder,blinkRate);

    }
 function showBorder(){
       $("#border_icon").addClass("with_border");
       setTimeout(removeBorder,blinkRate);
    }

   $('#border_icon').click(function() {
       $('#border_icon').addClass("with_border");

       setTimeout(removeBorder,blinkRate);
  });

</script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When it comes to printing, the @Media CSS rule

I have a specific structure on my HTML page: <html> <head></head> <body> <nav> .... navigation menu </nav> <div> <div></div> <div class="to-print"> <h2>Th ...

SyntaxError: The input on line one ended unexpectedly and was not caught

This issue is commonly associated with messy close parentheses, however, the error is occurring on line 1 of the file! Below is the javascript code from (filename: calculate.js) var colors = new Array(); colors["SILVER"] = -2; ... Although there is m ...

A step-by-step guide on implementing ng-annotate to your code

Is there a way to run ng-annotate through the command line? I am attempting to combine and minify Angular, Angular Routes, and my own script.js into one file. When I use grunt uglify:app1, I encounter an injection error. While my code successfully minifies ...

Function is not triggered in React component

When the LoginPage calls AuthForm, the structure is as follows: function mapDispatchToProps(dispatch: Redux.Dispatch<any>) { return { signUpWithEmail: function(email: string, password: string) { // bla bla }, }; } handleForm ...

Combine the PHP table with the Javascript table

I am facing a challenge where I have a table in PHP and another table in Javascript. My goal is to combine the elements of the PHP table with the elements of the Javascript table. I attempted to achieve this using the push method: <?php $tabPHP=[&apos ...

Ensure child elements do not surpass parent size in HTML/CSS/Javascript without altering the children directly

I am intrigued by how iframes neatly encapsulate all site data within a frame and adjust it to fit the size. Is there any method to achieve this functionality in an HTML wrapper? Can the wrapper be configured so that regardless of the content, it is dis ...

Allow the content to be scrolled

When it comes to my CSS script, I encounter no issues on larger computer screens. However, users with smaller resolutions like 1024 x 768 are experiencing problems viewing the entire HTML page. Only half of the page is displayed, making it impossible for t ...

Centered on the screen are the input field and corresponding label

I am in the process of creating a signup form, and I have encountered an issue. How can I make the input wider without using a fixed width like width: 420px? Additionally, I would like to center both the input field and the label. I envision something simi ...

How can I place a DOM element without relying on style properties?

Before diving in, let me provide some context. I am currently developing a visual element that operates similar to a spreadsheet. It features scrollable content areas in both directions, with axis indicators on the left and top that remain visible at all t ...

Utilizing object UUID keys to associate products in VueJS

Hey there, I've gone ahead and created an object with UUIDs but now I'm looking for a way to link these UUIDs to specific items. It seems like there needs to be some separation between the UUID and the rest of the object, however, my main issue i ...

Is it possible to retrieve the IMEI number of a mobile phone using expo?

Currently working on developing a mobile app with React Native using Expo. I need to figure out a way to access the client's mobile IMEI number and display it in the front end of the app. Unsure of how to accomplish this task. Is there a method to do ...

Error in Angular: Unexpected '<' token

After setting up my angular and express app using the angular-cli and express command lines, I successfully built the angular app with the ng build command. However, when attempting to serve it with the express server, I encountered the following error in ...

Reorganize divisions using Bootstrap

I am exploring different ways to manage responsiveness through the reordering of divs. While I am aiming for a solution that is highly flexible, any suggestion would be appreciated. Desktop View: https://i.stack.imgur.com/boSOa.png Mobile View: https:// ...

Head styles for tinyMCE

When viewing the tinyMCE example on the official website using Firefox, you may notice the editor blinking. This issue seems to only occur in Firefox, possibly due to external CSS files for the editor. I am considering adding all CSS rules directly into th ...

React Animation Library With Smooth Initial Render and No Dependency on External Props

I'm currently implementing a Modal component within my app, utilizing Portals. My goal is for the Modal to smoothly fade in when it is rendered and fade out when it is no longer displayed. Upon examining the documentation for react-transition-group, ...

How can I add an SVG tooltip that appears when I hover my

I have successfully implemented an SVG map showing marked locations and polygons, with CSS styling that makes the areas stand out on hover. I achieved this without using any JavaScript code. My next goal is to create a hovering window or tooltip that disp ...

Ways to showcase a list in 3 columns on larger screens and 1 column on smaller screens

When viewing on a computer, my list appears like this: However, when I switch to a phone, only the first column is visible and the list does not continue in a single column format. I am utilizing Bootstrap for my layout, and here is a snippet of my code: ...

Tips for simulating a service in Angular unit tests?

My current service subscription is making a promise: getTaskData = async() { line 1 let response = this.getTaskSV.getTaskData().toPromise(); line 2 this.loading = false; } I attempted the following approach: it('should load getTaskData', ...

What causes the disappearance of CSS styles when attempting to modify the className in react js?

I am currently working on a basic react application, and I am trying to dynamically change the name of a div element using the following code snippet - <div className={'changeTab ' + (page.login ? 'leftSide' : 'rightSide')} ...

Searching through a JSON object on a Laravel web page using JavaScript or AJAX for live filtering purposes

After diving into AJAX and JavaScript, I find myself needing to replace some outdated Angular functionality on our Laravel site. The specific task at hand is creating a live search filter for a page with a static header search bar. The main requirement is ...