How to change the position of a tooltip div in leaflet marker on dragging the map - leaflet

I have some markers in the leaflet map. On clicking a marker a tooltip div appears to show a chart and some information. If after that I drag the map the tooltip window remains in the same position but the markers position is changed.
I am using the following function to change the marker position
function update() {
markers.attr("transform", function(d) {
if(d.code==clickedcode)
{
console.log((map.latLngToLayerPoint([ d.lat, d.lon ]).x) + "px , "+(map.latLngToLayerPoint([ d.lat, d.lon ]).y - 80) + "px");
div.style["left"]=(map.latLngToLayerPoint([ d.lat, d.lon ]).x) + "px";
div.style["top"]=(map.latLngToLayerPoint([ d.lat, d.lon ]).y - 80) + "px";
}
return "translate("
+ map.latLngToLayerPoint([ d.lat, d.lon ]).x + ","
+ map.latLngToLayerPoint([ d.lat, d.lon ]).y + ")";
});
}
I am also trying to change the div position. But its not changed. How can I change the div position along with the change of position of map due to dragging.

Related

Get animation object location value when drag other object in Google Web designer

I want to get animation object.location in gwd when drag other object .
Animation Object is moving y axis and drag item is waiting to get that animation object x axis.
What should I do ?
Dragstart code event
gwd.dragger = this;
event = (event.changedTouches ? event.changedTouches[0] : event);
gwd.s = window.getComputedStyle ? getComputedStyle(this, null) : this.currentStyle;
gwd.dX = event.pageX - parseInt(gwd.s["left"]);
gwd.dY = event.pageY - parseInt(gwd.s["top"]);
Dragmove drag event
if (gwd.dragger) {
event = (event.changedTouches ? event.changedTouches[0] : event);
gwd.actions.events.setInlineStyle(gwd.dragger.id, "left:" + (event.pageX - gwd.dX) + "px; top:" + (event.pageY - gwd.dY) + "px");
}
Dragstop event
gwd.dragger = null;
I want to get animated item left and top values pixel when drag
You can see this my ads.
https://doc-14-10-adspreview.googleusercontent.com/preview/9o5bees06oeguhr10neq55qcti27eh7n/2ma5s2dmjnvulveo4uos4qfu7ifos8ps/1664409600000/90358308/previewuser/gwd.90358308?render=blank&creativeId=gwd.90358308&irsk=CICAgODErP3t8gE&ecId=AOgHqNpAgFX7nq3p6KSPl2n47gS0-gxu3Aa9jhkOsuFMEnrCJDOlIJQMG7XhxKQuzLKQN98dGl9n

Camera focus an object center

Pick up the exactly center position of object in my code i use onmousedown function inside this function pick the click position i want center an object in the screen
private void OnMouseDown()
{
Camera.main.GetComponent<PanZoom>().thisGameObject = ParentThis.gameObject;
if (_center)
{
Debug.Log("Show Popup");
Popup.SetActive(true);
}
else
{
Vector3 groundPos = GetWorldPosAtViewportPoint(.5f, .5f);
Debug.Log(groundPos);
Debug.Log("groundPos: " + groundPos);
groundCamOffset = Camera.main.transform.position - groundPos;
Debug.Log("Camera pos " + Camera.main.transform.position);
camTarget = Camera.main.transform.position;
float mouseX = Input.mousePosition.x / Camera.main.pixelWidth;
float mouseY = Input.mousePosition.y / Camera.main.pixelHeight;
Debug.Log("Mousex " + Input.mousePosition.x + " : " + Camera.main.pixelWidth + " Mousey " + Input.mousePosition.y + " : " + Camera.main.pixelHeight);
Debug.Log("Mx " + ParentThis.transform.localPosition.x + " My " + ParentThis.transform.localPosition.y);
Vector3 clickPt = GetWorldPosAtViewportPoint(mouseX, mouseY);
camTarget = clickPt + groundCamOffset;
Go = true; // For Camera movement //!?
}
}
I would in this case advise you to read more about Cinemachine, as it has functionality where you can make it change to look at a camera target. Please note that Cinemachine must first be installed via the package manager in Unity.

css style transform

I wanted to be able to put into effect the css transform property depending on the size of a container with respect to the size of the enclosing window.
With the following code, scaleCameraShutter() is called. Zooming does occur with the re-written code for scaleCameraShutter()and the scaling is accurate.
Here's the only remaining problem = window resizes and so does the container. THEN, I do a reload of the window and the correct zooming totally disappears. In short, the zooming is only temporary, not permanent??
Since this Board thrives on code, the .css specs are at the bottom ...
$(window).bind('resize', function() {
scaleCameraShutter(); // below, container is GLOBAL
});
I call:
function scaleCameraShutter() {
// .width() returns "###px"
// value before scaling
var containerWidth = parseInt( container.width() );
var windowWidth = parseInt( $(window).width() );
var theScale = windowWidth/containerWidth;
var maxContainerWidth = 480;
if (windowWidth > maxContainerWidth)
{
theScale = maxContainerWidth/containerWidth;
}
// Let the Browser pick the parm it accepts:
// IE 10 and Firefox
container.css("-transform" , "scale(" + theScale + ", " + theScale + ")");
// IE 9
container.css("-ms-transform" , "scale(" + theScale + ", " + theScale + ")");
// Firefox
container.css("-moz-transform" , "scale(" + theScale + ", " + theScale + ")");
// Chrome and Safari
container.css("-webkit-transform", "scale(" + theScale + ", " + theScale + ")");
// Opera
container.css("-o-transform" , "scale(" + theScale + ", " + theScale + ")");
}
Last, here's the css:
#container {
position: relative;
margin: 0 auto;
width: 30.00em;
height: 22.50em;
}
As Far as I know, you are passing only one value to SCALE. Try doing one of the following:
scale(x,y) Defines a 2D scale transformation
scale3d(x,y,z) Defines a 3D scale transformation
scaleX(x) Defines a scale transformation by giving a value for the X-axis
scaleY(y) Defines a scale transformation by giving a value for the Y-axis
scaleZ(z) Defines a 3D scale transformation by giving a value for the Z-axis
http://www.w3schools.com/cssref/css3_pr_transform.asp
good luck.

MenuItemLabel callback not working, never calls the callback, but the MenuItemImage works

Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Vector<MenuItem*> menuItems;
auto label = Label::createWithTTF("Space Combat", "fonts/Marker Felt.ttf", 24);
label->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
this->addChild(label, 1);
auto closeItem = MenuItemImage::create("CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(MainMenu::menuCloseCallback, this));
closeItem->setPosition(origin.x + visibleSize.width - closeItem->getContentSize().width/2,
origin.y + closeItem->getContentSize().height/2);
menuItems.pushBack(closeItem);
auto playLabel = Label::createWithTTF("Play", "fonts/Marker Felt.ttf", 24);
playLabel->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height *2));
auto playItem = MenuItemLabel::create(playLabel, CC_CALLBACK_1(MainMenu::menuPlayCallback, this));
menuItems.pushBack(playItem);
auto menu = Menu::create();
menu->addChild(closeItem);
menu->addChild(playItem);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
auto sprite = Sprite::create("HelloWorld.png");
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
this->addChild(sprite, 0);
return true;
}
The above code will call my menuCloseCallback when the MenuItemImage is clicked on, but won't do the same for the MenuItemLabel.
Figured it out. I was positioning the label, but the menu item was being placed in the default location of 0,0 anchor 0,0. Once i added the label and positioned the menu item, all was well.

Compass to annotation with Titanium

I'am trying to build a compass that heading to a annotation with Titanium on a map. It's already succeeded me to build a normal compass with the compass function in Titanium.
I am unable to make the compass point the right direction from the location. Has anyone a script or example what works?
if (Titanium.Geolocation.hasCompass){
var transform = Ti.UI.create2DMatrix();
// Settings
Titanium.Geolocation.showCalibration = true;
Titanium.Geolocation.headingFilter = 0;
Ti.Geolocation.getCurrentHeading(function(e){
if (e.error){
Titanium.API.info("error: " + e.error);
return;
}
var animationNorth = Titanium.UI.createAnimation({
transform : transform.rotate(e.heading.trueHeading),
duration : 50
});
// Rotate image to north
compassNorth.animate(animationNorth);
headingLabel.setText('geo - current heading: ' + e.heading.trueHeading);
});
Titanium.Geolocation.addEventListener('heading', function(e){
if (e.error){
Titanium.API.info("error: " + e.error);
return;
}
var animationNorth = Titanium.UI.createAnimation({
transform : transform.rotate(e.heading.trueHeading),
duration : 50
});
// Rotate image to north
compassNorth.animate(animationNorth);
headingLabel.setText('geo - current heading: ' + e.heading.trueHeading);
});
} else {
headingLabel.setText("No Compass on device");
}