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

  • Home
  • SEARCH
  • 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 8402971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:13:12+00:00 2026-06-09T22:13:12+00:00

I have a somewhat interesting problem I am having a hard time figuring out.

  • 0

I have a somewhat interesting problem I am having a hard time figuring out. I am implementing a draggable div from outside the map, and would like to drag it onto the map. I have gotten as far as triggering the event and grabbing the position of the drop, but now I need to translate that into something the map will understand.

Is there a way to convert the values returned by .position() into a latlng or point that google maps will understand? I have been messing with the map projections, but can’t seem to get it to work relative to the viewport on the map. Any point in the right direction would be terrific.

$('#map').droppable({
        drop: function(e, ui) {
            console.log(e);
            console.log(ui);
            var rawMouseLocation = $('#map').mapPlugin('mouseLocation', ui.position);


            mouseLocation = rawMouseLocation.toString().replace(/[()]/g,'')
            var field = $(ui.draggable[0]).data('fieldID');
            var iconPath = $(ui.draggable[0]).find('img').attr('src');

            $('.'+field).val(mouseLocation).removeClass('default-text');
            var layerName = $('#map').mapPlugin('addNewFieldLayer',field, rawMouseLocation, {
                "iconPath":iconPath, 
                'onDragEnd':self.updateField
                });
            newLayers.push(layerName); 
            $(ui.draggable).draggable( 'disable' );
        }
    });

Inside of the ‘mouseLocation’ function, I need a way to convert that position into the map coordinates. I am not even sure this is possible, but any help would be greatly appreciated. Thanks.

  • 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-06-09T22:13:13+00:00Added an answer on June 9, 2026 at 10:13 pm

    I was able to come up with a solution which uses the map overlayView.

     // bunch of stuff to get an overlay set up to convert a pixel location to a lat/long
                MyOverlay.prototype = new google.maps.OverlayView();
                MyOverlay.prototype.onAdd = function() { }
                MyOverlay.prototype.onRemove = function() { }
                MyOverlay.prototype.draw = function() { }
                function MyOverlay(map) { this.setMap(map); }
    
                overlay = new MyOverlay(aMap);
    
                google.maps.event.addListener(aMap, 'idle', function() { 
                    // Get projection
                    projection = overlay.getProjection();
                })
    

    and then in my mouseLocation function, I do this:

      // need to convert mouse location into a lat/long point
             var point = new google.maps.Point(eventPosition.pageX, eventPosition.pageY);
                var latlng= projection.fromContainerPixelToLatLng(point);
                return latlng;
    

    which has the latlng of the mouse location! Thanks! @Vesliq

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

Sidebar

Related Questions

I need to extract a value from a hidden HTML field, have somewhat figured
I have a somewhat strange issue with visual studio. Almost every time I create
I have a somewhat-long-running stored procedure being called from a PB application. I want
Salutations everyone, I have a somewhat strange problem with my repo. Initial I only
I have somewhat of a problem. We have a centralized interface engine that will
I have interesting problem with my UiimageViews. I have an application (game with 2
I have an interesting problem. I am developing for a .Net2.0 solution. I have
I am somewhat new to objective c and have run into an interesting issue.
I have somewhat of a problem. My old webserver (windows 2003) have been replaced,
I have an interesting problem, however I don't know quite how to articulate it

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.