I love the new polygon drawing options and have been playing with them for a couple of days.
On the official documentation I see that it is possible to initiate the drawing of a polygon by clicking on a button external to the map. Does anybody know how to do this?
http://code.google.com/apis/maps/documentation/javascript/overlays.html#updating_the_drawing_tools_control
In other words I would like to be able to create a button similar to the "Delete selected shape", but which will instead start the drawing of the polygon:
http://googlegeodevelopers.blogspot.com/2011/11/make-your-map-interactive-with-shape.html
Use setDrawingMode() function of the google.maps.drawing.DrawingManager object.
In the button click event handler, call:
drawingManager.setDrawingMode(google.maps.drawing.OverlayType.POLYGON);
To quit the drawing mode, call:
drawingManager.setDrawingMode(null);
Related
I have a layer with a number of polygons, where the layer is marked as NOT being an infolayer
myLayer = new Layer() { IsMapInfoLayer = false...
I also have an eventhandler for clicking the map defined in the xaml
MapClicked="myClickHandler"
This click works well on empty areas, but if I click a polygon, the map click is blocked. Previously I solved this by responding to the info event handler for the polygons and route that to the same code that handled map clicks, but that is not enough now, as I need the lat,lng of the clicked position.
How do I make the polygons not intercept my click?
If a feature is clicked the MapInfo event is called. If not the MapClicked event is called. This is by design. You mention IsMapInfoLayer is set to false. In that case no MapInfo event should be triggered and you should get a MapClicked event. Note, that the MapInfo event could also be triggered from another layer.
A workaround for your problem: The MapInfo event also contains the WorldPosition but it is on SphericalMercator coordinates. You can translate that with:
var latLon = Projection.SphericalMercator.ToLonLat(point.X, point.Y);
I have an application that shows tracking data. With the map, and the track, I have a chart that show the speed of each point of the polilyne. When I move over the chart, the same point in the maps is highlighted.
What I need to do is: when I move the pointer over the polyline on the map, also highlight the point on the chart, for this, I need to get the nearest point from the polyline to the mouse pointer on the map.
I binded the polyline mousemove event, but I can't find any property that helps me.
the point(latLng) is a property of the mouseEvent
google.maps.event.addListener(polylineInstance, 'mousemove',function(e){
console.log(e.latLng)
})
To get the clicked segment of the Polyline, iterate over the path of the Polyline, create a temporarily polyline for each segment and use google.maps.geometry.poly.isLocationOnEdge() to check if the click has been on the current segment.
I have a QwtPlot that contains some curves and I would like to be able to get the selected point(s) (and curve pointer) from these curves : select a point by clicking and select points by dragging a rect.
I use the following code:
// Picker with click point machine to provide point selection
QwtPlotPicker* clickPicker = new QwtPlotPicker(this->canvas());
clickPicker->setStateMachine(new QwtPickerClickPointMachine);
clickPicker->setMousePattern(0,Qt::LeftButton,Qt::SHIFT);
connect(clickPicker, SIGNAL(appended(QPointF)),
this, SLOT(pointSelected(QPointF)));
// Picker with drag rect machine to provide multiple points selection
QwtPlotPicker* rectPicker = new QwtPlotPicker(
this->xBottom, this->yLeft, QwtPicker::RectRubberBand,
QwtPicker::AlwaysOff, this->canvas());
QwtPickerDragRectMachine* test = new QwtPickerDragRectMachine();
test->setState(QwtPickerMachine::RectSelection);
rectPicker->setStateMachine(test);
connect(rectPicker, SIGNAL(selected(QRectF)),
this, SLOT(pointsSelected(QRectF)));
but the pointSelected slot is called every time I click on the QwtPlot and not only on a curve
BTW, I also try to connect a slot to the signal QwtPlotPicker::selected(const QVector &pa) but it is never emitting ...
I think it is more convenient to use the CanvasPicker as it comes with the examples and can be extended easily.
Please have a look at the event_filter which comes with Qwt. You should use the class CanvasPicker (it is not part of the Qwt API, but you'll find the code in the examples).
You can instantiate it in your class using
picker = new CanvasPicker(plot); // plot is a pointer to your instance of QwtPlot
You'll see that the event filter is installed in the constructor of CanvasPicker.
Now have a look at CanvasPicker::eventFilter(QObject *object, QEvent *e) which is called when an event occurs in the event loop of QwtPlot. Implement your application logic in the switch construct, f.i. change case QEvent::MouseMove:.
Hi am trying to connect two flex graphic objects using drag and drop (drag from source shape and drop on target, then a line is created that connect the two, using path object).
Is there any way that i can see a preview of the line while i am dragging between the shapes?
Update a data object whenever the object moves, and bind the endpoints of the line to that data object.
I'm trying to find the best way to create a personalized contact List for an instant messaging app.
Maybe with a Tree View but I'm not sure.
I Need a way to view Groups in which there are Contacts.
A Contact contains different info and action buttons like "Send a message, View infos, ... "
An example # http://ycorpblog.com/wp-content/uploads/2007/10/yahoo-messenger-90-action-toolbar.jpg
here I am in my little research. I inherited one of my classes QAbstractItemDelegate.
I reimplements paint () and sizeHint ()
in the paint () for drawing my items (and here for example a button)
Code:
QStyleOptionButton buttonStyle;
buttonStyle.rect = option.rect;
buttonStyle.features = QStyleOptionButton::AutoDefaultButton;
buttonStyle.text = "Salut!";
QApplication::style()->drawControl(QStyle::CE_PushButton,&buttonStyle,painter);
But then it does involve reimplementing QAbstractItemDelegate: helpEvent () to retrieve the actions of clicking the buttons (compare the position of the mouse compared to my drawing and determine what the user clicks)?
Moreover, with the solution proposed above,
QAbstractItemDelegate::helpEvent () is a slot
Despite a careful reading of the documentation, I can not determine when this function is called, does it connect to something?
I also cast a glance at editorEvent (), I recovered well Mouse Click but no way of knowing exactly where the user clicked, so no way of knowing if it's a button or other element.
I asked about the method I use too. Is this good? Can you enlighten me?
Pending your answers / ideas. Thank you.