private void mymap_TouchDown(object sender, TouchEventArgs e) { if (check == 1) { MapLayer layer2 = new MapLayer(); e.Handled = true; // Determin the location to place the pushpin at on the map. //Get the mouse click coordinates TouchPoint touchp = e.GetTouchPoint(this); //Convert the mouse coordinates to a locatoin on the map Location pinLocation = mymap.ViewportPointToLocation(touchp.Position); PushPinControl asdfgh = new PushPinControl(pinLocation); layer2.AddChild(asdfgh, pinLocation, PositionOrigin.Center); // The pushpin to add to the map. // Pushpin pin = new Pushpin(); // pin.Location = pinLocation; //mymap.Children. // Adds the pushpin to the map. // mymap.Children.Add(pin); // asdfgh.pinno.Content = count; mymap.Children.Add(layer2); count++; check = 0; Drop_controler.Tag = "isdisabled"; } }
public void load_pushpins() { SqlCeConnection conn = null; string filesPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NatureNetDataBase_Main.sdf"); string connectionString = string.Format("Data Source=" + filesPath); conn = new SqlCeConnection(connectionString); SqlCeCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT COUNT(*) AS NumberOfOrders FROM PushPin_location"; conn.Open(); object value4 = cmd.ExecuteScalar(); for (int i = 1; i <= Convert.ToInt32( value4); i++) { double x_position; double y_position; cmd.CommandText = "SELECT x_position FROM PushPin_location WHERE (pin_tag = N'"+i+"')"; x_position = Convert.ToDouble( cmd.ExecuteScalar()); cmd.CommandText = "SELECT y_position FROM PushPin_location WHERE (pin_tag = N'" + i + "')"; y_position = Convert.ToDouble(cmd.ExecuteScalar()); MapLayer layer2 = new MapLayer(); Location pinLocation = new Location(x_position,y_position); PushPinControl asdfgh = new PushPinControl(pinLocation); layer2.AddChild(asdfgh, pinLocation, PositionOrigin.Center); // The pushpin to add to the map. // Pushpin pin = new Pushpin(); // pin.Location = pinLocation; //mymap.Children. // Adds the pushpin to the map. // mymap.Children.Add(pin); // asdfgh.pinno.Content = count; mymap.Children.Add(layer2); } conn.Close(); }