How to show multiple Pushpins Windows Phone 8 - windows-phone

Someone pls fix this code for me. I cant show multiple pushpins :(
Or give me some link about show pushpins. Ty :)
// Creat point
GeoCoordinate p1 = new GeoCoordinate(21.0178, 105.8303);
GeoCoordinate p2 = new GeoCoordinate(21.0076, 105.8414);
// Show center map
this.myPushpins.Center = p1;
this.myPushpins.ZoomLevel = 13;
// Creat Pushpins
Pushpin pp = new Pushpin();
// Creat MapOverLap
MapOverlay overlay1 = new MapOverlay();
overlay1.Content = pp;
overlay1.GeoCoordinate = new GeoCoordinate(21.0178, 105.8303);
MapOverlay overlay2 = new MapOverlay();
overlay2.Content = pp;
overlay2.GeoCoordinate = new GeoCoordinate(21.0076, 105.8414);
// Creat Maplayer
MapLayer layer = new MapLayer();
layer.Add(overlay1);
layer.Add(overlay2);
myPushpins.Layers.Add(layer);

You are setting the content of both overylay1 and overylay2 to the same Pushpin object instance. You need to have two different instances of Pushpin. Try this code:
// Creat point
GeoCoordinate p1 = new GeoCoordinate(21.0178, 105.8303);
GeoCoordinate p2 = new GeoCoordinate(21.0076, 105.8414);
// Show center map
this.myPushpins.Center = p1;
this.myPushpins.ZoomLevel = 13;
// Creat Pushpins
//Pushpin pp = new Pushpin();
// Creat MapOverLap
MapOverlay overlay1 = new MapOverlay();
overlay1.Content = new Pushpin();
overlay1.GeoCoordinate = new GeoCoordinate(21.0178, 105.8303);
MapOverlay overlay2 = new MapOverlay();
overlay2.Content = new Pushpin();
overlay2.GeoCoordinate = new GeoCoordinate(21.0076, 105.8414);
// Creat Maplayer
MapLayer layer = new MapLayer();
layer.Add(overlay1);
layer.Add(overlay2);
myPushpins.Layers.Add(layer);
Or even better to have some function to display your pins
public void PinMap(Map map, GeoCoordinate geoPosition) {
map.Center = geoPosition;
map.ZoomLevel = 13;
var mapOverlay = new MapOverlay();
mapOverlay.Content = new Pushpin();
mapOverlay.GeoCoordinate = geoPosition;
var mapLayer = new MapLayer();
mapLayer.Add(mapOverlay);
map.Layers.Add(mapLayer);
}
PinMap(myMap, new GeoCoordinate(21.0178, 105.8303));
PinMap(myMap, new GeoCoordinate(21.0076, 105.8414));

Related

C# Aspose BarCode QRCode low quality or small size

I have an issue with adding a QR-code to my pdf file.
If I use code like this (with new Bitmap), the resulting image quality is very low.
If use barCodeBuilder.ImageQuality = ImageQualityMode.AntiAlias; the quality is absolutely awful.
var barCodeBuilder = new BarCodeBuilder();
barCodeBuilder.CodeText = resultString;
barCodeBuilder.EncodeType = !qrCode ? EncodeTypes.Code128 : EncodeTypes.QR;
barCodeBuilder.AutoSize = false;
barCodeBuilder.Resolution = new Resolution(300, 300, ResolutionMode.Graphics);
barCodeBuilder.ImageHeight = 4000;
barCodeBuilder.ImageWidth = 4000;
// becomes even worse
//barCodeBuilder.ImageQuality = ImageQualityMode.AntiAlias;
var documentBuilder = new DocumentBuilder(document);
documentBuilder.MoveToField(field, false);
documentBuilder.InsertImage(new Bitmap(barCodeBuilder.GetOnlyBarCodeImage(), !qrCode ? new Size(200, 30) : new Size(100, 100)));
If I use code without new Bitmap, the resulting image is extremely small.
var barCodeBuilder = new BarCodeBuilder();
barCodeBuilder.CodeText = resultString;
barCodeBuilder.EncodeType = !qrCode ? EncodeTypes.Code128 : EncodeTypes.QR;
barCodeBuilder.AutoSize = false;
barCodeBuilder.Resolution = new Resolution(300, 300, ResolutionMode.Graphics);
barCodeBuilder.ImageHeight = 4000;
barCodeBuilder.ImageWidth = 4000;
// becomes even worse
//barCodeBuilder.ImageQuality = ImageQualityMode.AntiAlias;
var documentBuilder = new DocumentBuilder(document);
documentBuilder.MoveToField(field, false);
documentBuilder.InsertImage(barCodeBuilder.GetOnlyBarCodeImage());

How do I add a radius line from the center of the circle to a point on the circle

The following code adds a circle of given radius to the graphics layer on an ArcGIS map. How can I add a line that joins center of the circle to any point on the circle to the graphics layer.
Basically the question is how do I calculate a point on the circle, draw a line that joins the center to the point on the circle and add it to the graphics layer.
performSearchPoint : function(e) {
var self = this;
var radius = $('#radius-distance').val();
if(radius > 0 && radius < 100000){
$('#besideMouse').removeClass('hide');
$('#besideMouse').show();
var loadingBMint = setInterval(this.loadingBM, 0);
var searchPointClick = OURAPP.App.Map.on("click",function(evt) {
loadingBMint = clearInterval(loadingBMint);
$('#besideMouse').hide();
var radius = $('#radius-distance').val();
var units = $("input:radio[name='unitsGroup']:checked").val();
if (units == "miles"){
units = "9035"; // if we use GeometryService
} else {
units = "9003"; // if we use GeometryService
}
//clear only search graphics
for ( var gr in OURAPP.App.Map.graphics.graphics) {
if(OURAPP.App.Map.graphics.graphics[gr].infoTemplate != null){
var template = OURAPP.App.Map.graphics.graphics[gr].infoTemplate;
if(template != "undefined" || template != null){
if(template.title.trim() == "Search Graphic"){
OURAPP.App.Map.graphics.remove(OURAPP.App.Map.graphics.graphics[gr]);
}
}}}
/*do buffer geometry for draw circle and use the circle geometry to get the features*/
var geoService = new OURAPP.esri.GeometryService("http://XXXX:YYYY/arcgis/rest/services/Utilities/Geometry/GeometryServer");
var params = new OURAPP.esri.BufferParameters();
params.geometries = [ evt.mapPoint ];
params.distances = [ radius ];
params.unit = units;
params.bufferSpatialReference = OURAPP.App.Map.spatialReference;
params.outSpatialReference = new OURAPP.esri.SpatialReference(4326);
var bufferPolygon = new OURAPP.esri.Polygon;
bufferPolygon.spatialReference = new OURAPP.esri.SpatialReference(4326);
geoService.buffer(params,function(geometries) {
var symbol = new OURAPP.esri.SimpleFillSymbol()
.setColor(null).outline.setColor("red");
dojo.forEach(geometries,function(geometry) {
geometry.spatialReference = new OURAPP.esri.SpatialReference(4326);
var graphic = new OURAPP.esri.Graphic(geometry,symbol);
// add name to identify the search graphics
var template = new OURAPP.esri.InfoTemplate(graphic.geometry);
template.setTitle("Search Graphic");
template.setContent("Map Query circle with Radius: " + radius);
graphic.setInfoTemplate(template);
OURAPP.App.Map.graphics.add(graphic);
bufferPolygon = geometry;
OURAPP.App.Map.setExtent(graphic.geometry.getExtent().expand(2));
});
self.searchType="Distance Search from point";
self.nameofplace=radius + " "+$("input:radio[name='unitsGroup']:checked").val();
self.showCount(bufferPolygon);
});
searchPointClick.remove();
});
}
},
I was able to draw a line and add it to the graphics layer using the following. The [-XX.XXXXXXXXXXXX,YY.YYYYYYYYYYY] is a random point on the map, Now only thing left is to find a point on a circle. So now the question becomes how to find a point which is X miles from a known point(Center of the circle) along the same latitude.
var lineSymbol = new OURAPP.esri.CartographicLineSymbol(
OURAPP.esri.CartographicLineSymbol.STYLE_SOLID,
new OURAPP.esri.Color([255,0,0]), 2,
OURAPP.esri.CartographicLineSymbol.CAP_SQUARE,
OURAPP.esri.CartographicLineSymbol.JOIN_MITER, 5
);
var lineGeometry = new OURAPP.esri.Polyline;
lineGeometry.spatialReference = new OURAPP.esri.SpatialReference(4326);
lineGeometry.addPath([[evt.mapPoint.getLongitude(),evt.mapPoint.getLatitude()], [-XX.XXXXXXXXXXXX,YY.YYYYYYYYYYY]])
var lineGraphic = new OURAPP.esri.Graphic(lineGeometry, lineSymbol);
OURAPP.App.Map.graphics.add(lineGraphic);
This is the best possible one i came up with and its working.
var lineSymbol = new OURAPP.esri.CartographicLineSymbol(
OURAPP.esri.CartographicLineSymbol.STYLE_SOLID,
new OURAPP.esri.Color([255,0,0]), 2,
OURAPP.esri.CartographicLineSymbol.CAP_SQUARE,
OURAPP.esri.CartographicLineSymbol.JOIN_MITER, 5
);
var radiusInMeters;
if (selectedUnit == "miles"){
radiusInMeters = radius*1609.34; //have to convert it to meters.
} else {
radiusInMeters = radius*0.3048; //have to convert it to meters.
}
// Calculate the new map point on the circle.
var radians = Math.PI/180;
var ltLong = OURAPP.esri.webMercatorUtils.xyToLngLat(evt.mapPoint.x + radiusInMeters*Math.cos(radians), evt.mapPoint.y + radiusInMeters*Math.sin(radians));
// Calculate the new map point on the circle.
var lineGeometry = new OURAPP.esri.Polyline;
lineGeometry.spatialReference = new OURAPP.esri.SpatialReference(4326);
lineGeometry.addPath([[evt.mapPoint.getLongitude(),evt.mapPoint.getLatitude()], ltLong]);
var lineGraphic = new OURAPP.esri.Graphic(lineGeometry, lineSymbol);

CreateJS - Collision detection between two createjs.Containers

I currently have this working in a desktop browser but not on touch devices because I update the variables I need on mouseover. So to get around this I am trying to check for collision detection between two containers and then update the needed variables. The items should snap to the placeholder positions when a collision between the two is detected. The catch is that items and placeholders are placed dynamically any item must be able to snap to any placeholder.
var placeholders,items,selectedItem,collision,startX, startY, snapX, snapY, xpos, ypos;
var stage = new createjs.Stage("canvas");
createjs.Touch.enable(stage);
createjs.Ticker.addEventListener("tick", tick);
function init(){
xpos = 0;
ypos = 120;
container = new createjs.Container();
stage.addChild(container);
placeholders = new createjs.Container();
placeholders.name = "placeholders"
stage.addChild(placeholders);
items = new createjs.Container();
stage.addChild(items);
for(i=0;i<2;i++){
placeholder = new CustomContainer(i, "#ff0000", 100,100);
placeholder.setBounds(0,0,100,100);
placeholder.cursor = "pointer";
placeholder.x = xpos;
placeholder.name = "placeholder"+i
container.addChild(placeholder)
xpos+= (placeholder.getBounds().width + 10);
}
xpos = 0;
for(j=0;j<2;j++){
item = new CustomContainer(j, "#0000ff", 100,100);
item.active = false;
item.setBounds(0,0,100,100);
item.name = "item"+j;
item.x = xpos;
item.y = ypos;
item.startX = xpos;
item.startY = ypos;
container.addChild(item)
item.addEventListener("mousedown", selectItem);
xpos+= (item.getBounds().width + 10);
}
stage.addChild(placeholders,items);
}
function selectItem(evt) {
selectedItem = evt.target.parent;
selectedItem.mouseEnabled = false;
evt.addEventListener("mousemove", function(ev) {
moveItem(ev);
})
evt.addEventListener("mouseup", function(ev) {
selectedItem.mouseEnabled = true;
if(collision){
//New position based on the hitTest
//selectedItem.x = ;
//selectedItem.y = ;
}else{
selectedItem.x = selectedItem.startX;
selectedItem.y = selectedItem.startY;
}
})
}
function moveItem(evt){
pt = placeholders.globalToLocal(stage.mouseX, stage.mouseY);
obj = evt.target.parent;
obj.x = pt.x - 50;
obj.y = pt.y - 50;
//selectedItem collision with placeholder
collision = obj.hitTest(pt.x,pt.y)
}
function tick(evt) {
stage.update();
}
$(document).ready(init());
I am just not getting the hitTest right. You can see the working code below.
http://jsfiddle.net/non_tech_guy/2d68W/4/
The hittest will test pixel-perfect hit. I believe you're looking for a collision test.
Try this: https://github.com/olsn/Collision-Detection-for-EaselJS

Special character doesn't appear the same on windows phone emulator and real device

my problem is a bit strange!! I'm going to create a calendar tile with writable bitmap for windows phone 8. so I'm using this character "📆".
I'm using the below code and everything works fine as I expected on emulator. but when I test my app on a real device,calendar character will be appeared different
private void RenderText9()
{
int width = 159;
int height = 159;
string imagename = "SmallBackground";
WriteableBitmap b = new WriteableBitmap(width, height);
var canvas = new Grid();
canvas.Width = b.PixelWidth;
canvas.Height = b.PixelHeight;
var background = new Canvas();
background.Height = b.PixelHeight;
background.Width = b.PixelWidth;
SolidColorBrush backColor = new SolidColorBrush((Color)Application.Current.Resources["PhoneAccentColor"]);
background.Background = backColor;
var textBlock = new TextBlock();
textBlock.Text = "25";
textBlock.TextAlignment = TextAlignment.Center;
textBlock.Margin = new Thickness(0, 72, 0, 0);
textBlock.Width = 159;
textBlock.TextWrapping = TextWrapping.Wrap;
textBlock.Foreground = new SolidColorBrush(Colors.White);
textBlock.FontSize = 35;
var textBlock2 = new TextBlock();
textBlock2.Text = "📆";
textBlock2.TextAlignment = TextAlignment.Center;
textBlock2.Margin = new Thickness(0, 40, 0, 0);
textBlock2.Width = 159;
textBlock2.TextWrapping = TextWrapping.Wrap;
textBlock2.Foreground = new SolidColorBrush(Colors.White); //color of the text on the Tile
textBlock2.FontSize = 75;
canvas.Children.Add(textBlock);
canvas.Children.Add(textBlock2);
b.Render(background, null);
b.Render(canvas, null);
b.Invalidate(); //Draw bitmap
//Save bitmap as jpeg file in Isolated Storage
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/" + imagename + ".jpg", System.IO.FileMode.Create, isf))
{
b.SaveJpeg(imageStream, b.PixelWidth, b.PixelHeight, 0, 100);
}
}
}
this is the tile on both emulator and real device(pay attention to difference).
anybody knows any solution??? I don't understand the reason !!

How do I programmatically capture and replicate Ai path shape?

I'm using ExtendScript for scripting Adobe Illustrator. I was wondering if there was a sneaky way or a script available to programmatically capture and then replicate a path shape, sort of JavaScript's .toSource() equivalent.
Thanks
Try this:
main();
function main(){
var doc = app.activeDocument; // get the active doc
var coords = new Array(); // make a new array for the coords of the path
var directions = new Array();
var sel = doc.selection[0];// get first object in selection
if(sel == null) {
// check if something is slected
alert ("You need to sevlect a path");
return;
}
var points = sel.pathPoints;// isolate pathpoints
// loop points
for (var i = 0; i < points.length; i++) {
// this could be done in one lines
// just to see whats going on line like
//~ coords.push(new Array(points[i].anchor[0],points[i].anchor[1]));
var p = points[i]; // the point
var a = p.anchor; // his anchor
var px = a[0];// x
var py = a[1]; // y
var ldir = p.leftDirection;
var rdir = p.rightDirection;
directions.push(new Array(ldir,rdir));
coords.push(new Array(px,py));// push into new array of array
}
var new_path = doc.pathItems.add(); // add a new pathitem
new_path.setEntirePath(coords);// now build the path
// check if path was closed
if(sel.closed){
new_path.closed = true;
}
// set the left and right directions
for(var j = 0; j < new_path.pathPoints.length;j++){
new_path.pathPoints[j].leftDirection = directions[j][0];
new_path.pathPoints[j].rightDirection = directions[j][1];
}
}