/** * This method is called if the touch-up event was inside the * bounds of the button. * @param button The button object that generated the event. */ void MainScreen::buttonClicked(Widget* button) { if (button == mGetVisibleAreaButton) { MapRegion region; mMap->getVisibleArea(region); mVisibleAreaCoordinatesLabel->setText("UL la: " + MAUtil::doubleToString(region.getUpperLeftCorner().getLatitude()) + " UL lo: " + MAUtil::doubleToString(region.getUpperLeftCorner().getLongitude()) + " LR la: " + MAUtil::doubleToString(region.getLowerRightCorner().getLatitude()) + " LR lo: " + MAUtil::doubleToString(region.getLowerRightCorner().getLongitude())); } else if (button == mSetVisibleAreaButton) { mMap->setVisibleArea(32.1234, 22.123124, 11.231123, 12.32344); } else if (button == mSetZoomLevel) { mMap->setZoomLevel(MAUtil::stringToInteger(mZoomLevelEditBox->getText())); mZoomLevelEditBox->hideKeyboard(); } else if (button == mAddPinToMap) { for (int i = 0; i < 20; i++) { // generate random values for the coordinates // get a random latitude and longitude double latitude = (double)(rand() % 80); double longitude = (double)(rand() & 170); int longSign = rand()%2; if (longSign == 0) longitude *= (-1); int latSign = rand()%2; if (latSign == 0) latitude *= (-1); MapPin *newPin = new MapPin(Location(latitude, longitude)); newPin->setText("test title"); mMapPins.add(newPin); mMap->addMapPin(newPin); } } else if (button == mRemovePinFromMap) { for (int i = 0; i < mMapPins.size(); i++) { mMap->removeMapPin(mMapPins[i]); } } else if (button == mSetCenterButton) { mMap->setCenter(MapLocation(32.43, 43.34, 11)); mMap->centerMap(); } }
static void TrackPopup( gui_window *wnd, gui_point *location, MENUITEM *new_menu, gui_mouse_track track, gui_ctl_id *curr_id ) { MapLocation( wnd, location ); MenuState = MENU_FLOAT; uipushlist( NULL ); uipushlist( GUIUserEvents ); GUICreateMenuPopup( wnd, location, new_menu, track, curr_id ); uipoplist( /* GUIUserEvents */ ); uipoplist( /* NULL */ ); MenuState = MENU_NONE; GUIFreeMenuItems( new_menu ); }
MapLocation MapLocation::getRelative(int x, int y, int z) const { return MapLocation(getX() + x, getY() + y, getZ() + z); }
// Non modifying addition MapLocation operator+(const MapLocation & p1, const MapLocation & p2){ return MapLocation(p1) += p2; }