Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4561604
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:05:53+00:00 2026-05-21T18:05:53+00:00

In my HTML5 app, I use Google Map v3 and add several markers on

  • 0

In my HTML5 app, I use Google Map v3 and add several markers on a map. It’s easy to place new markers and to change icons but I’d like to be able to build markers like the one used in Google Latitude. Those markers are set up with an icon image and a nice border.
Any ideas on how to do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:05:53+00:00Added an answer on May 21, 2026 at 6:05 pm

    You could do this server-side or since you are using HTML 5 and assuming you have the canvas available you could do this on the client-side. Below is a way to do it client-side using the HTML 5 canvas. Doing it server-side will vary by what language you are using but the technique would be similar.

    Download these images and try it out. The images need to reside in the same domain as the page to avoid a security error. They should also be in the same directory unless you update the locations in the HTML.

    face1face2face3frame

    After the page loads, click the faces and a random marker will be created using the supplied frame image and added to the Google map.

    enter image description here

    <!DOCTYPE html>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; utf-8">
            <title>HTML 5 Canvas Image Processing</title>
        </head>
        <body>
            <img onclick="build(this)" id="face1" src="face1.png"/>
            <img onclick="build(this)" id="face2" src="face2.png"/>
            <img onclick="build(this)" id="face3" src="face3.png"/>
            <img id="frame" src="frame.png"/>
            <div id="map_canvas" style="width:640px;height:480px;">
            </div>
            <script type="text/javascript">
    
                function build(caller){
                    var image = getMergedUrl(document.getElementById("frame"), caller);
                    var myLatLng = getRndPos(map.getBounds());
                    var myMarker = new google.maps.Marker({
                        position: myLatLng,
                        map: map,
                        icon: image
                    });
    
                }
    
                function getRndPos(bounds) {
                    var xDiff = Math.abs(bounds.getNorthEast().lng() - bounds.getSouthWest().lng());
                    var yDiff = Math.abs(bounds.getNorthEast().lat() - bounds.getSouthWest().lat());
                    var xMin = Math.min(bounds.getNorthEast().lng(),bounds.getSouthWest().lng());
                    var yMin = Math.min(bounds.getNorthEast().lat(),bounds.getSouthWest().lat());
                    var x = xMin + xDiff * Math.random();
                    var y = yMin + yDiff * Math.random();
                    var pos = new google.maps.LatLng(y,x);
                    return pos;
                }
    
                function getMergedUrl(frame, pic){
                    // Create an empty canvas element
                    var canvas = document.createElement("canvas");
                    canvas.width = frame.width;
                    canvas.height = frame.height;
    
                    // Copy the image contents to the canvas
                    var ctx = canvas.getContext("2d");
                    ctx.drawImage(frame, 0, 0);
                    ctx.drawImage(pic, 4, 4);
    
                    // Get the data-URL formatted image
                    var dataURL = canvas.toDataURL("image/png");
    
                    return dataURL;
                }
    
                function initialize(){
                    var myLatlng = new google.maps.LatLng(-34.397, 150.644);
                    var myOptions = {
                        zoom: 8,
                        center: myLatlng,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    }
                    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                }
    
                function loadScript(){
                    var script = document.createElement("script");
                    script.type = "text/javascript";
                    script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
                    document.body.appendChild(script);
                }
    
                window.onload = loadScript;
            </script>
        </body>
    </html>
    

    Thanks to Matthew Crumley for the toDataUrl code from here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load a html page through UIWebview.I need to disable all
IE is giving me an undefined NAN when i try to view the calender...
I have a script that appends some rows to a table. One of the
We manage a site for a medical charity. They have a number of links
I'm trying to build a C++ extension for python using swig. I've followed the
This is beyond both making sense and my control. That being said here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.