private void gMap_MouseDown(object sender, MouseEventArgs e) { /* if there's any project marker clicked while a green push-pin marker is clicked * green push-pin marker should be disappeared * */ if (currMarker is GMarkerGoogle && !(currMarker is ProjectMarker)) { foreach (GMapMarker marker in mouseOveredMarkers) { if (marker is ProjectMarker) { // remove current marker mouseOveredMarkers.Remove(currMarker); markersOverlay.Markers.Remove(currMarker); currMarker.Dispose(); currMarker = null; // refresh gMap gMap.Refresh(); break; } } } // determine current marker if (mouseOveredMarkers.Count > 0) { currMarker = mouseOveredMarkers.Last(); } // add new marker while right mouse button downed else if (e.Button == MouseButtons.Right && GPLC.AuthVerify(GPLCAuthority.Administrator)) { setCurrMarker(gMap.FromLocalToLatLng(e.X, e.Y)); } gMap.Refresh(); }
private void gMap_OnMarkerClick(GMapMarker item, MouseEventArgs e) { // GMapMarker marker = (mouseOveredMarkers.Count > 0) ? mouseOveredMarkers.Last() : item; // display clicked latlng on textbox textBox_latlng_lat.Text = string.Format("{0:0.00000}", marker.Position.Lat); textBox_latlng_lng.Text = string.Format("{0:0.00000}", marker.Position.Lng); // double check to avoid inconsistency : check if clicked item really in mouseOvered marker list if (mouseOveredMarkers.Contains(item)) { // left mouse button clicked : add a project or view a project if (e.Button == MouseButtons.Left) { // view a project if (item is ProjectMarker) { ProjectData pd = (marker as ProjectMarker).ProjectData; // set text box textBox_project_id.Text = pd.id.ToString(); textBox_project_name.Text = pd.name; richTextBox_project_addr.Text = pd.addr; // get marker local position GPoint pos = gMap.FromLatLngToLocal(item.Position); // set map center //this.gMap.Position = gMap.FromLocalToLatLng((int)pos.X, (int)pos.Y + gMap.Height / 4); viewProject(item); } // add a project else if (GPLC.AuthVerify(GPLCAuthority.Administrator)) { inputProject(item); } } // modify a project else if (e.Button == MouseButtons.Right && GPLC.AuthVerify(GPLCAuthority.Administrator)) { if (item is ProjectMarker) { inputProject(marker); } } } }