You are almost there. When the icons should be draggable to the map from every position in document you'd also have to consider the position and size of the map and the size of the marker icons
http://www.wolfpil.de/v3/drag-from-outside.html On Dec 16, 4:04 pm, Matt <[email protected]> wrote: > Changing the title... > > On Wednesday, December 15, 2010 2:57:52 PM UTC-6, Matt wrote: > > Hey all, > > So I'm trying to implement a way to drag-n-drop <img>'s on to a map. > It's generally working fine, but, if I zoom or pan the map then the > coordinates (for the dropped <img>) are offset by however much I > zoomed or panned. I uploaded a demo of the code in action > here:http://mattpowell.name/google-maps-example.html > > But the gist is, I'm creating a fake overlay proto like this: > > google.maps._overlay=function (map) {this.setMap(map);} > google.maps._overlay.prototype = new > google.maps.OverlayView(); > google.maps._overlay.prototype.onAdd = function(){} > google.maps._overlay.prototype.onRemove = function(){} > google.maps._overlay.prototype.draw = function() {} > > Instantiating my fake overlay whenever I create my map: > > var map=new google.maps.Map($("map"),{}) > var overlay=new google.maps._overlay(map); > > And in a dragend event getting the latlong like this: > > var projection = overlay.getProjection(); > var latlong = projection.fromDivPixelToLatLng(new > google.maps.Point(event.clientx, event.clienty)) > > Then adding a marker to the map the usual way. > > It seems like I just need to tell my overlay to update whenever the > main map moves, but nothing I've tried has worked. > > Anyways, I appreciate the help and let me know you need more info, > etc... > > Matt -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
